Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to Mount/Unmount A Disk...

Hi all

Maybe someone can help me with this... I'm trying to create a set of scripts to use with Chronosync to mount and unmount my external firewire drive before and after a sync operation...

I had gotten this to work in the past by searching for the drive's name (since its mount point can change, as I recall) but I seem to have misplaced this code...

I also need a delay in the mount script until it is actually mounted so Chronosync doesn't bomb out...

Thanks!

Mac Pro 2.66, 1.0 GB RAM, 23 Apple Cinema HD Display, Mac OS X (10.4.7), EyeTV 200, Powerbook G4/667, 512 MB RAM

Posted on Nov 2, 2006 4:46 PM

Reply
Question marked as Best reply

Posted on Nov 2, 2006 6:19 PM

--Assuming the name you have given to the drive is "External FW" try this:

set driveName to "External FW"
set driveInfo to do shell script "diskutil list | grep \"" & driveName & "\""
set driveID to last word of driveInfo
--In the following:
--TO MOUNT (use mount to mount just the single volume, if the disk is partitioned, or use mountDisk to mount all volumes on the disk)
--To UNMOUNT (use unmount for just the single volume, or use unmountDisk for all volumes)
--For example:
do shell script "diskutil mount " & driveID & ""
--do shell script "diskutil unmount " & driveID & ""

--I'm assuming you can work this into any remaining
--script you need. The "unmount" can be pretty slow.
--An alternative is:


tell application "Finder"
eject driveName
end tell

--but there's no Finder equivalent for "mount"
23 replies

Nov 4, 2006 7:23 PM in response to Justin Surpless

Okay, I'm back on the 10.4.6 partition, but I was able to install 10.4.7 on an otherwise identical backup partition. I didn't see any issues with mount/unmount using 10.4.7

All Mac Pro's are Intel, no?

Assuming you have an Intel, just out of curiosity open Terminal and, at the command prompt, type in man diskutil and press return. (Don't know whether you've used Terminal, but to scroll through all the "man" info use the space bar.) In any event, under "verbs" just check to see if "mount" and "unmount" are there and if here are any caveats. (Of course, maybe needed updates aren't there.)

If you want to pursue this more, open Disk Utility, select the volume you want to manipulate, and click on "info." What you want is the Disk Identifier, e.g., disk0s7. Now, in Terminal, enter diskutil mount disk0s7 (or whatever) OR diskutil unmount disk0s7, and press return.

See if this brings forth any request for a password

Nov 5, 2006 6:16 AM in response to Justin Surpless

That pretty much it puts it with Intel version of Tiger.

What would seem to be needed is a password avoidance command in the last portion of the script. I've seen a lot of attention to passwords in UNIX but haven't paid much attention. If someone else doesn't jump in with a solution, then there's some work to do here.

Have you determined that external drives are definitely immune to this? If so, any possibility that you can use an external drive until some solution surfaces.

Nov 5, 2006 6:18 AM in response to Justin Surpless

That pretty much puts it with the Intel version of Tiger.

What would seem to be needed is a password avoidance command in the last portion of the script. I've seen a lot of attention to passwords in UNIX but haven't paid much attention. If someone else doesn't jump in with a solution, then there's some work to do here.

Have you determined that external drives are definitely immune to this? If so, any possibility that you can use an external drive until some solution surfaces.

Nov 6, 2006 7:37 PM in response to Justin Surpless

Good for Niel! -- and good for you for getting someone to "jump in" with your new post.

Even though I don't have an Intel Mac, I did find that by adding "sudo" in front of the command in Terminal, I was prompted (as expected) for a password (interestingly, this didn't happen with the do shell script approach). So maybe I have a way of looking at the changes to the authorization file . . .

I don't suppose this had any effect on unmount speed? I was thinking that perhaps there could be a relationship. I probably should post a question on this, as it's perplexing why unmount is so slow in AS when it's so fast in Terminal.

Anyway, thanks for keeping me up to date.

Applescript to Mount/Unmount A Disk...

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.