LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-14-2008, 10:12 AM   #1
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
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?
 
Old 11-14-2008, 10:13 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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
 
Old 11-14-2008, 09:41 PM   #3
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Original Poster
Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
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.
 
Old 11-15-2008, 02:01 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by frieza View Post
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..
 
Old 11-15-2008, 05:09 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 11-15-2008, 06:26 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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.

Last edited by i92guboj; 11-15-2008 at 06:27 PM.
 
Old 11-16-2008, 10:35 AM   #7
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Original Poster
Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to remove the blank lines in the file naveensankineni Programming 7 03-25-2008 08:34 PM
Bash script creates blank file name snowman81 Programming 9 03-02-2008 10:37 PM
Some mtPaint images inserted into Abiword are blank BuilderQ Linux - Software 2 10-03-2007 11:25 AM
Error when blank data CD is inserted Quercus ruber Linux - Hardware 4 03-08-2005 03:56 AM
Blank entries inserted into mysql database sandoz Programming 4 09-22-2003 03:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration