Bash script to automate copying data from [CDs][1][?][1].

Detects media insertion (via HAL, using polling *blegh*)

!/bin/bash

cdcopy.sh: copy a data CD to disk

 mark AT cognomen DOT co DOT uk

CDROM=$1     # CD-ROM device
MNTPNT=$2    # CD-ROM mount point
OF=/data/         # output directory

eject $CDROM
UDI=hal-find-by-property --key block.device --string $CDROM | tail -n1

while ((1)) ; do
        if [ hal-get-property --udi $UDI --key storage.removable.media_available == 'true' ]
        then
                mount $CDROM
                if ((! $?))
                then
                        echo; echo "Copying the source CD to $OF."
                        cp -av $MNTPNT/* $OF || echo Copy failed

                else
                        echo; echo "Failed to mount CD. Ejecting"
                fi
                eject $CDROM
        fi
        sleep 3
done

$[Get Code]2

Download

cdcopy.sh