Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whitman

macrumors member
Original poster
Jan 4, 2008
67
2
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?
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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.
 

Attachments

  • Picture 6.png
    Picture 6.png
    109.1 KB · Views: 337

whitman

macrumors member
Original poster
Jan 4, 2008
67
2
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.
 

Attachments

  • Screen Shot 2013-05-01 at 16.39.09.png
    Screen Shot 2013-05-01 at 16.39.09.png
    70 KB · Views: 272
  • mount-disSD.app.zip
    1.5 MB · Views: 154

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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
 

Attachments

  • Screen Shot 2013-05-02 at 14.18.48.png
    Screen Shot 2013-05-02 at 14.18.48.png
    33.7 KB · Views: 206
  • Screen Shot 2013-05-02 at 14.19.30.png
    Screen Shot 2013-05-02 at 14.19.30.png
    11.6 KB · Views: 168
  • Screen Shot 2013-05-02 at 15.43.08.png
    Screen Shot 2013-05-02 at 15.43.08.png
    94.8 KB · Views: 201
  • ScreenRecUnMount.zip
    1.6 MB · Views: 78
  • ScreenRecMount.zip
    1.7 MB · Views: 111
Last edited:

whitman

macrumors member
Original poster
Jan 4, 2008
67
2
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?
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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.
 

Attachments

  • Picture 7.png
    Picture 7.png
    206.8 KB · Views: 285

whitman

macrumors member
Original poster
Jan 4, 2008
67
2
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.
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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.
 

Attachments

  • Screen Shot 2013-05-03 at 16.43.27.png
    Screen Shot 2013-05-03 at 16.43.27.png
    236 KB · Views: 312
Last edited:

whitman

macrumors member
Original poster
Jan 4, 2008
67
2
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".
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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 :
 

Attachments

  • Picture 1.png
    Picture 1.png
    142.9 KB · Views: 296
  • Picture 2.png
    Picture 2.png
    155.6 KB · Views: 289
  • Picture 3.png
    Picture 3.png
    148.2 KB · Views: 224

whitman

macrumors member
Original poster
Jan 4, 2008
67
2
Ta, Kryten. Me being dim. Everything is working fine. Thanks so much for your patience and help. Very much appreciated.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.