Go Back   MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Reply
 
Thread Tools Search this Thread Display Modes
Old May 1, 2013, 06:56 AM   #1
whitman
macrumors newbie
 
Join Date: Jan 2008
A better way to make Automator mount a volume?

I'm new to Automator (10.8.3). I made an Automator application, using the Record function, to mount a volume on a drive connected to my Mini. I also made a similar one to eject it. I use them as Calendar-triggered events as part of my backup scheme.

They work well ... until I restart the Mini, when occasionally my two connected drives will mount in a different order. What happens then is that the sequence of mouse clicks recorded in Automator donít find the correct volume.

I wonder if thereís a better way to automate the mounting of a currently ejected disc (and later its ejection). Automator, as far as I can see, does not have the actions I need. It has Ask For/Connect to/Get specified Servers, but they seem only to be for network-connected stuff.

Anyone know a better way?
whitman is offline   0 Reply With Quote
Old May 1, 2013, 09:03 AM   #2
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by whitman View Post
I'm new to Automator (10.8.3). I made an Automator application, using the Record function, to mount a volume on a drive connected to my Mini. I also made a similar one to eject it. I use them as Calendar-triggered events as part of my backup scheme.

They work well ... until I restart the Mini, when occasionally my two connected drives will mount in a different order. What happens then is that the sequence of mouse clicks recorded in Automator donít find the correct volume.

I wonder if thereís a better way to automate the mounting of a currently ejected disc (and later its ejection). Automator, as far as I can see, does not have the actions I need. It has Ask For/Connect to/Get specified Servers, but they seem only to be for network-connected stuff.

Anyone know a better way?
Check out the diskutil and hdiutil commands. Launch the Terminal application and type in man diskutil or man hdiutil, press enter. You can use them in a shell script or with Applescript's do shell script command.

Info : man page for diskutil and man page for hdiutil
__________________
Space Corps Directive 34124
kryten2 is offline   0 Reply With Quote
Old May 1, 2013, 09:32 AM   #3
whitman
Thread Starter
macrumors newbie
 
Join Date: Jan 2008
Quote:
Originally Posted by kryten2 View Post
Check out the diskutil and hdiutil commands. Launch the Terminal application and type in man diskutil or man hdiutil, press enter. You can use them in a shell script or with Applescript's do shell script command.

Info : man page for diskutil and man page for hdiutil
Thanks kryten. I found Automator uphill, but this is beyond me, I think. Can you explain what I'd need to do?
whitman is offline   0 Reply With Quote
Old May 1, 2013, 11:15 AM   #4
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by whitman View Post
Thanks kryten. I found Automator uphill, but this is beyond me, I think. Can you explain what I'd need to do?
I can try if you provide more information but it's not going to be easy. Search for Terminal in Spotlight. Launch it and paste or type the following line into the Terminal window with your two drives connected to your Mac and press enter :

Code:
diskutil list
The command should return some output like in the example attached tumbnail. Make a screenshot of the Terminal window and attach it to your reply. Provide more information as to which volume you would like to mount or unmount. Also attach your Automator app to your reply but save it first as a workflow.
Attached Thumbnails
Click image for larger version

Name:	Picture 6.png
Views:	40
Size:	109.1 KB
ID:	410415  
__________________
Space Corps Directive 34124
kryten2 is offline   0 Reply With Quote
Old May 1, 2013, 11:54 AM   #5
whitman
Thread Starter
macrumors newbie
 
Join Date: Jan 2008
Quote:
Originally Posted by kryten2 View Post
I can try if you provide more information but it's not going to be easy. Search for Terminal in Spotlight. Launch it and paste or type the following line into the Terminal window with your two drives connected to your Mac and press enter :

The command should return some output like in the example attached tumbnail. Make a screenshot of the Terminal window and attach it to your reply. Provide more information as to which volume you would like to mount or unmount. Also attach your Automator app to your reply but save it first as a workflow.
Kryten, much appreciated. There's a screenshot below of the Terminal window as instructed.

The volume I want to mount and to eject is "CLONE SprDpr".

I've also attached my Automator app.
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-05-01 at 16.39.09.png
Views:	28
Size:	70.0 KB
ID:	410421  
Attached Files
File Type: zip mount-disSD.app.zip (1.52 MB, 37 views)
whitman is offline   0 Reply With Quote
Old May 2, 2013, 10:23 AM   #6
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by whitman View Post
Kryten, much appreciated. There's a screenshot below of the Terminal window as instructed.

The volume I want to mount and to eject is "CLONE SprDpr".

I've also attached my Automator app.
Can you explain what your Calendar event does? Judging by the volume name and you stating it's part of your backup scheme I think it has something to do with super duper. The part of using disk utility to mount the volume I get but the rest is a bit of a mystery. I'm also a bit baffled by the fact that you have to manually mount/unmount a volume. When you connect an external disk all volumes should automount and show in the Finder. When you eject a disk that disk is no longer visible to the system. The only way to make an ejected disk visible again is to unplug and plug it back. You can try this GUI Applescript if you want. Search for Applescript Editor. You need to check enable access for assistive devices in Accessibility pane of System Preferences for this to work and your disk should be visible to the system. It will try to mount/unmount your "CLONE SprDpr" volume.


Code:
set theExitStatus to do shell script "mount | grep CLONE 1> /dev/null ; echo $?"

activate application "Disk Utility"
tell application "System Events"
	tell process "Disk Utility"
		set frontmost to true
		-- insert GUI Scripting statements here
		set myOutline to outline 1 of scroll area 1 of splitter group 1 of window "Disk Utility"
		set allRows to rows in myOutline
		set diskNameVals to value of static text of every row in myOutline
		repeat with i from 1 to (count diskNameVals)
			set diskNameVal to item 1 of item i of diskNameVals
			if (diskNameVal as string = "CLONE SprDpr") then
				tell row i of myOutline
					select
					delay 2
				end tell
				if theExitStatus = "1" then
					keystroke "M" using {command down, shift down}
				else
					keystroke "U" using {command down, shift down}
				end if
			end if
		end repeat
	end tell
end tell

delay 5
tell application "Disk Utility" to quit
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-05-02 at 14.18.48.png
Views:	16
Size:	33.7 KB
ID:	410596   Click image for larger version

Name:	Screen Shot 2013-05-02 at 14.19.30.png
Views:	12
Size:	11.6 KB
ID:	410597   Click image for larger version

Name:	Screen Shot 2013-05-02 at 15.43.08.png
Views:	21
Size:	94.8 KB
ID:	410598  

Attached Files
File Type: zip ScreenRecMount.zip (1.68 MB, 17 views)
File Type: zip ScreenRecUnMount.zip (1.64 MB, 8 views)
__________________
Space Corps Directive 34124

Last edited by kryten2; May 2, 2013 at 10:43 AM.
kryten2 is offline   0 Reply With Quote
Old May 2, 2013, 12:42 PM   #7
whitman
Thread Starter
macrumors newbie
 
Join Date: Jan 2008
Quote:
Originally Posted by kryten2 View Post
Can you explain what your Calendar event does? Judging by the volume name and you stating it's part of your backup scheme I think it has something to do with super duper. The part of using disk utility to mount the volume I get but the rest is a bit of a mystery. I'm also a bit baffled by the fact that you have to manually mount/unmount a volume. When you connect an external disk all volumes should automount and show in the Finder. When you eject a disk that disk is no longer visible to the system. The only way to make an ejected disk visible again is to unplug and plug it back. You can try this GUI Applescript if you want. Search for Applescript Editor. You need to check enable access for assistive devices in Accessibility pane of System Preferences for this to work and your disk should be visible to the system. It will try to mount/unmount your "CLONE SprDpr" volume.
Kryten, the Calendar event mounts the ejected volume of my WD Firewire-connected drive, just before my scheduled SuperDuper backup. It also runs a little later to eject the volume once again.

The bits that aren't identified in the sequence are the mouse-clicks to get to Disk Utility, and to close various windows afterward.

I don't want my drives mounted the rest of the time because they are noisy, even when idle, and distracting from my work.

As I said in my original post, this is all working fine ... except when I occasionally and inevitably have a restart, and my two connected drives then decide to mount in a different order. Then the sequence of mouse clicks recorded in Automator will not find the correct volume. So I've been looking for another way to do the same thing that doesn't need to physically find the correct volume in Disk Utility.

I'm not sure your script takes that into account, or do I misunderstand you?
whitman is offline   0 Reply With Quote
Old May 2, 2013, 02:46 PM   #8
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by whitman View Post
Kryten, the Calendar event mounts the ejected volume of my WD Firewire-connected drive, just before my scheduled SuperDuper backup. It also runs a little later to eject the volume once again.

The bits that aren't identified in the sequence are the mouse-clicks to get to Disk Utility, and to close various windows afterward.

I don't want my drives mounted the rest of the time because they are noisy, even when idle, and distracting from my work.

As I said in my original post, this is all working fine ... except when I occasionally and inevitably have a restart, and my two connected drives then decide to mount in a different order. Then the sequence of mouse clicks recorded in Automator will not find the correct volume. So I've been looking for another way to do the same thing that doesn't need to physically find the correct volume in Disk Utility.

I'm not sure your script takes that into account, or do I misunderstand you?
Did you run the script? Does it do what your Calendar event does? Did you look at the screenrecordings? Trust me it will not blow up your Mac it will only try to mount/unmount your "CLONE SprDpr" volume. If it`s ejecting that you want the script can be modified. Post a screenshot of Disk Utility with a numbered sequence of arrows.
  1. Select the "CLONE SprDpr" volume
  2. Click mount
  3. Do my Super Duper thing
  4. Select my "CLONE SprDpr" volume or the disk it resides on
  5. Click Unmount or Eject. There is a difference in result.
Attached Thumbnails
Click image for larger version

Name:	Picture 7.png
Views:	36
Size:	206.8 KB
ID:	410628  
__________________
Space Corps Directive 34124
kryten2 is offline   0 Reply With Quote
Old May 3, 2013, 08:55 AM   #9
whitman
Thread Starter
macrumors newbie
 
Join Date: Jan 2008
Quote:
Originally Posted by kryten2 View Post
Did you run the script? Does it do what your Calendar event does? Did you look at the screenrecordings? Trust me it will not blow up your Mac it will only try to mount/unmount your "CLONE SprDpr" volume. If it`s ejecting that you want the script can be modified. Post a screenshot of Disk Utility with a numbered sequence of arrows.
  1. Select the "CLONE SprDpr" volume
  2. Click mount
  3. Do my Super Duper thing
  4. Select my "CLONE SprDpr" volume or the disk it resides on
  5. Click Unmount or Eject. There is a difference in result.
Kryten, your powers are intact. I ran the script and it works perfectly to mount the volume - wherever it may reside in Disk Utility. Thank you!

Two more things I need to know, I think.
1. How do I modify the script to make a script to eject the same volume.
2. How do I then deploy the scripts as Calendar-triggered events?

I'm not clear what you mean by the numbered sequence.
whitman is offline   0 Reply With Quote
Old May 3, 2013, 09:19 AM   #10
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by whitman View Post
Kryten, your powers are intact. I ran the script and it works perfectly to mount the volume - wherever it may reside in Disk Utility. Thank you!

Two more things I need to know, I think.
1. How do I modify the script to make a script to eject the same volume.
2. How do I then deploy the scripts as Calendar-triggered events?

I'm not clear what you mean by the numbered sequence.
Thank you for trying the script and your feedback so you can forget about that numbered sequence.
  1. Run the script again. It will unmount the volume. Can you try this and see if the result is satisfactory?
  2. I'm working on my old G4 Mac mini right now. I'll fire up a ML machine to see if Calendar still supports running Applescripts. I'll also test putting the script into Automator. I'll let you know the results.

Edit : In Automator make a new Calendar Alarm with a Run Applescript action. Remove the on run handler part and copy the code from the script into the Run Applescript action. See attached tumbnail.
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-05-03 at 16.43.27.png
Views:	78
Size:	236.0 KB
ID:	410753  
__________________
Space Corps Directive 34124

Last edited by kryten2; May 3, 2013 at 10:44 AM.
kryten2 is offline   0 Reply With Quote
Old May 3, 2013, 11:38 AM   #11
whitman
Thread Starter
macrumors newbie
 
Join Date: Jan 2008
Quote:
Originally Posted by kryten2 View Post
Thank you for trying the script and your feedback so you can forget about that numbered sequence.
  1. Run the script again. It will unmount the volume. Can you try this and see if the result is satisfactory?
  2. I'm working on my old G4 Mac mini right now. I'll fire up a ML machine to see if Calendar still supports running Applescripts. I'll also test putting the script into Automator. I'll let you know the results.

Edit : In Automator make a new Calendar Alarm with a Run Applescript action. Remove the on run handler part and copy the code from the script into the Run Applescript action. See attached tumbnail.
Thanks Kryten. I've run the script again and it does indeed eject as well. Perfect.

I'm not quite with you on creating the Run Applescript action. Not sure what you mean by "remove the on run handler part".
whitman is offline   0 Reply With Quote
Old May 3, 2013, 02:34 PM   #12
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by whitman View Post
Thanks Kryten. I've run the script again and it does indeed eject as well. Perfect.

I'm not quite with you on creating the Run Applescript action. Not sure what you mean by "remove the on run handler part".
Example :
Attached Thumbnails
Click image for larger version

Name:	Picture 1.png
Views:	44
Size:	142.9 KB
ID:	410780   Click image for larger version

Name:	Picture 2.png
Views:	56
Size:	155.6 KB
ID:	410781   Click image for larger version

Name:	Picture 3.png
Views:	31
Size:	148.2 KB
ID:	410782  

__________________
Space Corps Directive 34124
kryten2 is offline   1 Reply With Quote
Old May 7, 2013, 09:33 AM   #13
whitman
Thread Starter
macrumors newbie
 
Join Date: Jan 2008
Ta, Kryten. Me being dim. Everything is working fine. Thanks so much for your patience and help. Very much appreciated.
whitman is offline   0 Reply With Quote
Old May 9, 2013, 05:28 PM   #14
themoffster
macrumors regular
 
Join Date: Apr 2011
Good for you kryten2 - its nice to see someone being so helpful
themoffster is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Mount a Directory as a Volume? AmestrisXServe Mac OS X Server, Xserve, and Networking 0 Feb 8, 2014 03:17 AM
Mount Parallels Volume from Boot Camp skallal Windows, Linux & Others on the Mac 0 Jan 31, 2014 07:43 PM
Make do with what you got - DIY iPhone Car Mount peapody iPhone Accessories 7 Sep 14, 2013 05:40 PM
Mount ssh volume with Applescript MacPC Windows, Linux & Others on the Mac 2 Feb 18, 2013 06:36 AM
Applescript to unmount/mount drive on identifier other than volume name? mixvio OS X 10.8 Mountain Lion 0 Sep 6, 2012 05:20 AM

Forum Jump

All times are GMT -5. The time now is 08:59 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC