Operating System - HP-UX
1826237 Members
3082 Online
109692 Solutions
New Discussion

[ What is the best way to find whether CD is present in CD ROM or no ]

 
madhavabk
Regular Advisor

[ What is the best way to find whether CD is present in CD ROM or no ]

Hi all ( Thanks in advance )

What is the best way to find that cd is existing in the cdrom. Assume that i have not mouted any cd. But just put cd in to the cdrom.

Also, is it that all the time cd will be reocgniged by c0t0d0 in /dev/dsk ?

11 REPLIES 11
Alex Lavrov.
Honored Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Mount I think is the only way to check if there is readable CD in cdrom.

If it's c0t0d0 now, it will always be c0t0d0 unless you change it. If you mena that on all systems it's c0t0d0, the answer is no.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Joseph Loo
Honored Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

hi,

i can only think of mount command.

to check which device file the CD-ROM belongs:

# ioscan -funC disk
look for CD-ROM under description column and the device file u may use to mount and check if any CD exists
# mount /dev/dsk/c#t#d# /CDROM

regards.
what you do not see does not mean you should not believe
Eric Antunes
Honored Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

You can also check this ejecting the CD (this will only work if the CD drive is not mounted!!)

Best Regards,

Eric Antunes
Each and every day is a good day to learn.
madhavabk
Regular Advisor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Joseph Loo : If c0t0d0 is not CDROM on all the machines then how we should find that which one is cdrom ?

Eric Antunes : I hope there is no eject command in HPUX. (if there ) How program will find that cd is present in CDROM by ejecting the CD ? If CD is mounted then we can simply grep for mount target in mount out put. And under DEVICE column i am not getting CD-ROM or any related words.

So i have following doubrs with the solutions got from you.


Eric Antunes
Honored Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Hi,

I think you didn't undrestood my point of view:

- you can only eject the cd if it isn't mounted;

- you can only mount the CD drive if there ia a valid CD in it and the drive is ok. To check if the drive is ok:

#ioscan -fnCdisk

Please post the ioscan results here...

Eric
Each and every day is a good day to learn.
Robert-Jan Goossens
Honored Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Hi,

# ioscan -fnkCdisk
disk 0 0/0/1/0.1.0 sdisk CLAIMED DEVICE HP DVD-ROM 304
/dev/dsk/c0t1d0 /dev/rdsk/c0t1d0
disk 1 0/0/1/1.2.0 sdisk CLAIMED DEVICE SEAGATE ST39103LC
/dev/dsk/c1t2d0 /dev/rdsk/c1t2d0
disk 2 0/0/2/0.2.0 sdisk CLAIMED DEVICE SEAGATE ST39103LC
/dev/dsk/c2t2d0 /dev/rdsk/c2t2d0

In my case the dvd/cdrom is c0t1d0

Regards,
Robert-Jan

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

What about fstyp ? That will tell you if there is a mountable CD in the drive:

fstyp /dev/dsk/c3t2d0

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Noel Miranda
Frequent Advisor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Use the diskinfo command.
Bill Hassell
Honored Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Just a note: there is no eject command in HP-UX. There are postings of programs that can perform a CD eject but you must download, compile and test the program.

The command:
ioscan -knfC disk

is the fastest way to determine where the CD drive is located, but you'll notice that all disks (not just CD drives) are listed. There is no way to filter ioscan beyond the disk class. The CD drive may be a DVD or CD-RM but this is dependent on the response from the CD itself. ioscan uses the SCSI ID command to determine the description. Note you can safely assume that the device file will be different on every machine. Many sysadmins will setup new machines by creating a /dev/rdsk/cdrom and /dev/dsk/cdrom devicefile so that they are easily identified.

However, the diskinfo command will work and it has the benefit of the "type:" field which reports "direct access" for disks and CD-ROM for CD drives. diskinfo will be immediate or take as much as 5-10 seconds to complete depending on HP-UX revision and patches.


Bill Hassell, sysadmin
TwoProc
Honored Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Try doing a "diskinfo" on it. I think that it may be the case that if there is no disk in that drive then it would return a "1"...

I've not tested it,
but the following might work...

#!/bin/ksh
diskinfo /dev/dsk/cdrom
if [ $? -ne 0 ]
then
echo "Error No Disk in Drive"
exit 1
fi
# Continue on as if disk is in drive...
We are the people our parents warned us about --Jimmy Buffett
Mark Ellzey
Valued Contributor

Re: [ What is the best way to find whether CD is present in CD ROM or no ]

Hi,

Here's a small script that will find the device file for the cdrom, and mount or unmount it.

Regards,
Mark