[Pythonmac-SIG] how to eject a volume through python

Nicholas Riley njriley at uiuc.edu
Thu Nov 20 12:26:24 EST 2003


On Thu, Nov 20, 2003 at 09:50:32AM +0100, Drew McCormack wrote:
> On the command line, you can  do this:
> 
> #!/bin/sh
> MOUNT_DIR=/Volumes/DiskToEject
> umount -f $MOUNT_DIR
> rm -r $MOUNT_DIR

This is a really bad idea; umount -f is still not guaranteed to
succeed, and you could send up wiping out the contents of your disk.

> /usr/sbin/disktool -r   # Refreshes disk status, so finder knows that 
> disk is gone

Just use disktool to eject the disk (or preferably diskutil, which is
a lot nicer to use).

-- 
=Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>



More information about the Pythonmac-SIG mailing list