Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

test the media in /dev/cdrecorder

Status
Not open for further replies.

pavNell

Technical User
Sep 27, 2002
178
US
For a shell script that I'm writing, I need to test if there is a cd-r disk in /mnt/cdrecorder and if there is, test if the cd-r disk is blank (no filesystem exists).

i.e.
#!/bin/sh

while a cd-r disk in /mnt/cdrecorder is not present or
a cd-r exists but has already been written to...
do
eject /mnt/cdrecorder
echo "Insert a blank cd-r and press some key"
read some_key
done
./my_burn_script.sh

^---This loops until the user inserts a valid blank cd-r.

Thanks for any input.

 
what is the command u are using to burn the cd
is there any way to check in that

if not then u can try the following

the command used is dd and my unix is SCO OpenServer 5.0.6 and my CD-RW is IDE

1. Blank Cd - dd returns the I/O error (error 5)
2. written cd - returns text of what ever is rtitten
3. Open CD Drive or No CD returns
NOTICE : Srom: Not working

so these can be chekde vi grep in ur script. it is not fool proof notr very elegant but workable to strat with

this checklist can also save u fromm errors from ejecting cdrom when drive is open or blank becasue responses are differnt in each case




[ponder]
----------------
ur feedback is a very welcome desire
 
Am using the cdrecord command to burn iso images made from the mkisofs command. I checked man pages for cdrecord, nothing that I could see that could be useful. I tried to evaluate return messages from a "mount /mnt/cdrecord" command but there's no distinction between a blank cd and an empty drive. Both return a 32 error code using. I'll try using dd and grep to evaluate return messages like you suggested. As long as I can get three different return messages/errors, I'm happy with that.

Now that I think about it, perhaps if I only test for an return error code of 5 (from dd). Anything else would not be desireable.

Thanks for your response.

 
yes cdrecord generates a lot of messages. so is reacd. or no message at all for some of the options.

u may try out some bad cd ans see what err code it returns

there could be some siiue to sort out. but it would be rare

now by bad cd it mean 2 tytpes. one that cannt be read atall and where ony soe files can be read.



[ponder]
----------------
ur feedback is a very welcome desire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top