supplementary notes

for my benefit

Thursday, September 24, 2009

⇒ mac code

useful script to find what's the holdup:

#!/bin/bash

PATH=${PATH}:/sbin:/usr/sbin

dr=($(drutil status | grep -i 'type:'))
devtype=${dr[1]}
device=($(mount | grep ${dr[3]}))
if [ $devtype = "No" ]
then echo No disk found. Sorry! >&2
exit 1;
fi
echo A $devtype is mounted on the device named $device
pids=($(sudo -p 'Please enter the administrator password:' lsof -t $device))
echo \nList of programs that may be preventing the disk to eject
ps -o pid,user,comm=COMMAND -www -p $(echo ${pids[*]} | sed 's/ /,/g')

Labels: ,

♥♣♦♠