I have a task in automator to make my backup, it runs shell script code, lot of code is working well but the unmount command doesn't works, I don't get unmount the unit after backup.

I checked to run my command successfully from terminal, It unmounts my drive well, all fine, but when It runs from my bash script in automator It doesn't unmounts the unit, no errors, it runs well, but it doesn't unmount. :(

My command used is: sudo diskutil unmountDisk disk3;

I have try with and without sudo, and I have the same problem.

I have tried diskutil eject command and same thing, it unmounts the unit typing it at hand from terminal, but from my automator shell script code it doesn't.

Any idea is very welcome.

1 Answer 1


When run from Automator how are you inputting your password when prompted by sudo? You're probably not being prompted if you're just running it the same way as if in Terminal.

You'll need to add some AppleScript code and run it via osascript so you're prompted for an Admin password:

osascript -e 'do shell script "sudo diskutil unmountDisk disk3" with administrator privileges'
  • Thank you, your solution works!. I didn't need sudo for it, so it is better. But sometimes my usb change the dev name. What command could I use to get the dev name associated to a volume name?
    – bunset
    May 28, 2016 at 18:53
  • 1
    @bunset, You can also use diskutil unmountDisk $MountPoint, e.g diskutil unmountDisk /Volumes/Untitled or diskutil unmountDisk $UUID. See the DEVICES section in the diskutil man page. "A device parameter to any of the above commands (except where explicitly required otherwise) is usually any of the following:", which you can read further in the man page. May 28, 2016 at 23:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .