LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Bash DVD burn (https://www.linuxquestions.org/questions/linux-general-1/bash-dvd-burn-536689/)

lpn1160 03-11-2007 09:47 PM

Bash DVD burn
 
I wrote a little shell script (that doesn't work 100%). I have 2 dvd burners I'm trying to make it so that if there's no disk in the first one it looks to the second device. It runs if there is a disk in the first drive. Here's my (bad) code:

#!/bin/bash

if [ dev/hdc ] ; then

growisofs -Z /dev/hdc=/$1 -dvd-compat -speed=16 && eject -v /dev/hdc

else

growisofs -Z /dev/hdd=/$1 -dvd-compat -speed=16 && eject -v /dev/hdd
fi

any help is GREATLY appreciated !!

Thank you

macemoneta 03-11-2007 11:17 PM

You want to use the dvd+rw-mediainfo command. A 251 return code indicates that no disk is loaded. For example:

Code:

/usr/bin/dvd+rw-mediainfo /dev/hdc &>/dev/null
if [ "$?" == "251" ]
then
  echo "No disk in /dev/hdc
fi
/usr/bin/dvd+rw-mediainfo /dev/hdd &>/dev/null
if [ "$?" == "251" ]
then
  echo "No disk in /dev/hdd
fi



All times are GMT -5. The time now is 03:46 PM.