LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 09-29-2008, 09:26 AM   #1
freeindy
Member
 
Registered: Nov 2002
Posts: 204

Rep: Reputation: 30
Cdrom tray status


Hi,

Is there anyway I can check status on weather the tray is open or close on my cd-rom drive in bash? The CD shouldn't be mounted once inserted. Only knowledge of that a CD is in the drive is sufficient.

Thanks

Indy
 
Old 09-29-2008, 02:06 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
One possible way would be to use hal.

If there's a disk in the drive then lshal should show it. If you run "lshal -m" (monitor mode) as you insert the disk, it will show you what entries get added. Then you can use "lshal |grep [one of those lines]" to determine when a disk is present. I believe it can display when a device is mounted as well.

Note that I'm not a hal expert though, so there are probably better ways to go about it.
 
Old 09-30-2008, 07:15 AM   #3
freeindy
Member
 
Registered: Nov 2002
Posts: 204

Original Poster
Rep: Reputation: 30
Hi david,

I only have hal-get-property. But I'm having some trouble using it. I also have to assume that system doen't have lshal utility. Is it still possible?

Indy
 
Old 09-30-2008, 08:40 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

If you've got cdrecord installed (you probably do), you can use:

$ cdrecord -V --inq dev=DEVICE 2>&1 | grep "medium not present"

replace DEVICE with /dev/whatever for the drive. If the grep returns a line (and exits with 0), there's nothing in the drive.

Dave
 
Old 09-30-2008, 01:30 PM   #5
freeindy
Member
 
Registered: Nov 2002
Posts: 204

Original Poster
Rep: Reputation: 30
ilikejam,

that works. Thanks. It's a shame that there is no simpler check... But one has to be thankfull for whatever one get...

Indy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to obtain a interrupt or signal to press the tray key of CDROM? freedomli Linux - Enterprise 0 12-04-2007 02:31 AM
hda status error related to /dev/cdrom on RHEL4 kernel 2.6.9-5smp erinduffy Linux - Kernel 0 11-01-2007 08:32 AM
Lock CDROM tray SmilinJoeFission Linux - Hardware 4 10-19-2007 05:30 PM
tray icons showing on desktop instead of tray cjae Linux - General 3 09-21-2006 06:27 PM
CDROM drive antics - ejects tray on boot lrt2003 General 8 12-14-2004 12:30 AM


All times are GMT -5. The time now is 03:01 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration