How to auto unload a usb drive
#1
I wanted to auto unload a 16 gig thumb drive I have for transporting all my TV recordings from my recorder at the office to home. I got tired to manually copying them off the thimb drive and unmounting them.

so I wrote this script....

#!/bin/bash

DRIVEDIR=/media/TV
VIDEODIR=/video/converted

DRIVEIN=$(ls /media | grep -c TV)
if [ $DRIVEIN = "1" ]; then
beep -f 200
beep -f 600
echo "Drive named TV detected. Starting move operation..."
mv $DRIVEDIR/*.avi $VIDEODIR 1> /dev/null 2> /dev/null
echo "File Move operation complete. Unmounting drive..."
beep -f 900
beep -f 1200
beep -f 600
umount /media/TV
fi


The above when attached to a crontab entry as root (sudo crontab -e) will run when you specify (I specify every minute) to look for a drive inserted and automounted called "TV" and then move it's contents to the desired directory, and unmount the drive.

works great. and it makes noise to let me know it's done. you need to sudo apt-get install crontab to get crontab on your XBMC live box.
Reply

Logout Mark Read Team Forum Stats Members Help
How to auto unload a usb drive0