Check drive?

All other development questions
LinuxNewby
Posts: 12
Joined: 21 Jan 2008, 15:18
Contact:

Check drive?

Postby LinuxNewby » 27 Feb 2008, 11:15

:shock: :shock:
its me again!
I am using the docache option and want to test if a CD is inside of the CD-drive, or I want to wait, until a cd is insert.
Now I googeld and found some ways checking this, but with help from a Programm or with checking a Path where the CD will be automountet...
SO anyone know, how can i check, if the cd is ejected or not?
I searched on CDRecord, but diddn't found a option...

admin
Site Admin
Posts: 2707
Joined: 17 Jul 2003, 09:44

Postby admin » 27 Feb 2008, 14:35

I think you can try to read a block from the device to know whether or not there is a cdrom.

I assume the cdrom device is /dev/sr0:

Code: Select all

if dd if=/dev/sr0 of=/dev/null count=1 2>/dev/null
then
        echo "there is a disc"
else
        echo "there is no disc"
fi

LinuxNewby
Posts: 12
Joined: 21 Jan 2008, 15:18
Contact:

Postby LinuxNewby » 28 Feb 2008, 09:07

yes it works, it checks if a cd ist insert thx, but i don't know if its ejectet or emty but this will work for the start.. thx..

LinuxNewby
Posts: 12
Joined: 21 Jan 2008, 15:18
Contact:

Postby LinuxNewby » 28 Feb 2008, 11:55

the Problem is,

Code: Select all

if dd if=/dev/sr0 of=/dev/null count=1 2>/dev/null

is true 1. if there is no disc and 2. if there is a empty disc inside...


Return to “Other”

Who is online

Users browsing this forum: No registered users and 1 guest