#!/bin/sh
# http://www.macosxhints.com/article.php?story=20040623231530448

if [ "$1" = "i" -o "$1" = "ipod" ]
	then
	_ej=duus\ ipod
	else
	_ej="$*"
EOF
fi
#
if [ -e "/Volumes/${_ej}" ]
	then
	echo "eject ${_ej}"
	echo | osascript <<EOF
	tell application "Finder"
	eject "${_ej}"
	end tell
EOF
	while [ -e "/Volumes/${_ej}" ]
		do
		echo "."
		sleep 2;
	done
	echo "${_ej} ejected.  It is now safe to remove."
	#
	else
	echo "${_ej} cannot be found."
fi
	

