LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   pause bash script unitil blank cd inserted in burner? (https://www.linuxquestions.org/questions/linux-general-1/pause-bash-script-unitil-blank-cd-inserted-in-burner-683383/)

frieza 11-14-2008 10:12 AM

pause bash script unitil blank cd inserted in burner?
 
is it possible to pause execution of a bash script at a predetermined spot and use a while loop of some nature to poll the status of the burner for presence of a cd and an if statement that either continues the script or if not blank echoes 'not a blank disc' and ejects it and continues waiting?

trickykid 11-14-2008 10:13 AM

Yeah, just have it sleep for a number of seconds until it discovers the blank cd, once the cd is there, it continues with the script.

man sleep

frieza 11-14-2008 09:41 PM

sorry, maybe i should be more specific
i've writtin a script to automate the process of converting multiple sequentially numbered avi files to MPG with mencoder and ffmpeg (yes i know usually just ffmpeg should work but i have encountered instances where it doesnt, however i havnt failed with mencoder then ffmpeg and on a quad core phenom the extra amount of time for mencoder at like 300 some fps is negligible), at the same time echos out the necessary XML info for dvdauthor into a dvdauthor.xml file then images the dvd with dvdauthor once the conversion process finishes, once the image mastering process is finished it burns the disk
however i would like to further the automation by having it get to the point where it finishes burning the disc, then starts then goes into a wait state until a new blank is inserted (perhaps by querying the status of the drive using cdrecord and if the disc is not blank or there is no disc in the drive), enter an infinite loop that queries the drive every few seconds UNTIL a blank is inserted then starts the next set, etc... until it runs out of avi files.

trickykid 11-15-2008 02:01 PM

Quote:

Originally Posted by frieza (Post 3342365)
sorry, maybe i should be more specific
i've writtin a script to automate the process of converting multiple sequentially numbered avi files to MPG with mencoder and ffmpeg (yes i know usually just ffmpeg should work but i have encountered instances where it doesnt, however i havnt failed with mencoder then ffmpeg and on a quad core phenom the extra amount of time for mencoder at like 300 some fps is negligible), at the same time echos out the necessary XML info for dvdauthor into a dvdauthor.xml file then images the dvd with dvdauthor once the conversion process finishes, once the image mastering process is finished it burns the disk
however i would like to further the automation by having it get to the point where it finishes burning the disc, then starts then goes into a wait state until a new blank is inserted (perhaps by querying the status of the drive using cdrecord and if the disc is not blank or there is no disc in the drive), enter an infinite loop that queries the drive every few seconds UNTIL a blank is inserted then starts the next set, etc... until it runs out of avi files.

Umm.. so yeah, why wouldn't a sleep command work in a while loop? Have it check for disc, no disc, sleep for 1 minute.. check again.. no disc, let's sleep again for 1 minute.. hey, let's see if this lazy schmuck has put in a disc yet.. oh there it is, glad he's still awake.. let's continue burning data to this new disc.. ;)

colucix 11-15-2008 05:09 PM

Why not simply?
Code:

read -p "Insert a blank CD then press enter... "
the user must be in front of the console to insert a blank CD, so he/she can always press a key to continue when ready. Then you can check if the CD is blank or not or directly try the cdrecord command and if it fails repeat again until the image is correctly burned onto the cd.

i92guboj 11-15-2008 06:26 PM

I did some quick research and it seems that HAL detects something each time that a blank cdrom is inserted. A visible difference is that the hal-device output will contain this string: "volume_empty_cd_r".

So, we could use that. Not clean, but it will work. Something in the lines of:

Code:

$ while ! hal-device | grep volume_empty_cd_r
> do
> sleep 5
> done; echo "you inserted a blank cd"
# here I pressed enter and after that, I inserted a blank cd
0: udi = '/org/freedesktop/Hal/devices/volume_empty_cd_r'
  info.udi = '/org/freedesktop/Hal/devices/volume_empty_cd_r'  (string)
you inserted a blank cd

I guess that there must exist a cleaner solution, involving hal or maybe dbus, to do this. However, I am not an expert in either of those. At most I can write udev rules but I haven't used so much the userland tools shipped with either hal or dbus. But while you wait for a better response, I guess that this will do.

frieza 11-16-2008 10:35 AM

well thx, the script im using is a quick and ditry hack i wrote so, as long as it works it doesnt matter if the solution is a quick and dirty hack ;)


All times are GMT -5. The time now is 02:24 AM.