how to know if there is a cd inside the cdwriter

David Rio drio at
Sun May 18 02:16:28 PDT 2003

On Sun, May 18, 2003 at 02:04:17AM -0400, Bob Hall wrote:
> David Rio <drio at> writes:
> > I am writing a little script to backup my data. I would like 
> > to know if there is a CD inside the cdwriter before launch the
> > burn process. Any idea?
> Here's a snippet from a bash script I use to do the same thing with 
> a dvd burner. The burner is external, so the script has alread checked 
> to see if the burner is mounted.
>         melding=$(sudo mount -t ufs -o rw /dev/cd0a $montering_punkt 2>&1)
>         #Om mount ikke returnerer 0, er noe galt.
>         if [ $? -ne 0 ]
>         then
>                 if [ "$melding" = "mount: /dev/cd0a: Device not configured" ]
>                 then

I have received another answer from Lowell Gilbert that point me to use 
"cdcontrol info" and then parse the output. This one is good too.

More information about the freebsd-questions mailing list