Run Script on Logout

I wish to unmount afp volumes at logout. I looked first, but only found Bombiuch’s loginwindow manager that can use shell scripts.

I have the applescript

umount /Volumes/Location of the mount

that I want to use at logout. How exactly do I do that?

Thanks, -Barry

To make a logout hook you need to make a shell script instead of a AppleScript. You can of course though utilize the shell command osascript to run AppleScripts from your shell script, but generally things on the system level are easily replicated in the terminal and a lot of the time with more options/power.

So one way to do this would be to make a shell script with the contens

Then save that .sh file somewhere and give it a chmod u+x

Finally set the logout hook

I would like to mention though that your applescript isn’t going to work because umount is not an actual command, so I assume you mean you have a shell command to do this in which case remove the osascript -e portion from the above bash command.

Hope that helps =)

I admit to being new to sh scripting. I am using Scriptgui to test the app prior to creating it via Terminal. When I run the script below, I get the error: Operation not permitted.

osascript -e ‘umount /Volumes/Art’

where “Art” is the network volume that I wish to unmount.

What am I missing?

umount is not an actual applescript command so try something along the lines of…

umount /Volumes/Art

Oops. typo.

I wrote:

umount /Volumes/Art

And got the error in Scriptgui when I tried to run it:

umount: unmount(/Volumes/Art): Operation not Permitted

Umm, let me download that app you mentioned and take a look, because the script works on my end… subustituting a appropriate volume of course.

[Edit] Okay it worked for me… through sudo in front of it…

sudo umount /Volumes/Art

How is this Volume being mounted btw?

“Art” is an afp network volume.

Using ‘Connect to Server’, afp://



diskutil unmount /Volumes/Art

a try

I think we are getting closer. I followed your suggestion

#! /bin/bash
diskutil unmount /Volumes/Art

& tried

#! /bin/bash
diskutil force unmount /Volumes/Art

but am getting this:

Disk Utility Tool
Usage: diskutil [mount(Disk)|unmount(Disk)|eject]
[Mount Point|Disk Identifier|Device Node]
Mount, unmount or eject local disks or volumes.
force is only valid on unmount or unmountDisk.
Example: diskutil unmount /Volumes/SomeDisk

Running this in Script Editor works.

tell application “Finder”
eject (every disk whose local volume is false)
end tell

Now, how can I turn this into a shell script?

Think I figured out this one. First, save the .scpt as run-only.
Then, I created a shell script thru terminal:

#! /bin/bash
open /path/to/

Thank you for your help! It was invaluable!