Skip to content

Instantly share code, notes, and snippets.

@raidzero
Created March 5, 2014 23:44
Show Gist options
  • Save raidzero/9379143 to your computer and use it in GitHub Desktop.
Save raidzero/9379143 to your computer and use it in GitHub Desktop.
Burn an iso to optical disc using cdrecord
#!/bin/sh
DEVICE="AUTO" # use the first detected drive. If this fails, hardcode a device, example 4,0,0
if [ ! -e "$1" ]; then
echo "File does not exist."
exit 1
fi
if [ "$DEVICE" == "AUTO" ]; then
DEVICE=`cdrecord -scanbus | grep "\-ROM" | awk '{print$1}'`
fi
# check to see if drive is valid
cdrecord dev="$DEVICE" -checkdrive
if [ $? -eq 0 ]; then
cdrecord -v dev="$DEVICE" "$1"
STATUS=$?
echo " "
if [ $STATUS -ne 0 ]; then
echo "Burn failed. If there was a disc in the drive, You probably just made a coaster."
exit 1
fi
else
echo "Drive does not exist. Check cdrecord -scanbus and set DEVICE manually."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment