Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-06-2004, 10:22 PM
|
#1
|
Member
Registered: Aug 2003
Location: Lewisville, TX
Distribution: Kubuntu
Posts: 295
Rep:
|
Manually remounting cd-rom drive stinks...
Ok, I went and got the 2.6.5 kernel from kernel.org, but yea of course supermount doesn't come with it. So anyways, I don't feel like downloading kernel-tmb-source (which has supermount) and recompiling (not right now, at least...)
So what I would like to do is have a shell script that does the following:
Code:
fuser /mnt/cdrom
(then it 'grabs' the process # and stores it in, say, $cd)
kill $cd
umount /mnt/cdrom
eject
That would eject the CD rom no matter what. I want it to see if there is a CD in the drive before it tries to eject it, if so then it ejects. And if there is no CD in the drive, then it does:
Code:
eject -t
mount /dev/cdrom /mnt/cdrom
Is this more trouble than it's worth? Should I just go ahead and spend the time compiling another kernel and reinstalling the NVidia drivers?
|
|
|
04-07-2004, 05:21 AM
|
#2
|
Member
Registered: Jul 2003
Location: Brighton, Michigan, USA
Distribution: Lots of distros in the past, now Linux Mint
Posts: 748
Rep:
|
For something like this, (and to make it easily accessible to whomever, even remotely) you could use a script (using grep/awk/etc.) that checks the output from 'df'. If there is an entry for /dev/cdrom (or whatever you cdrom is), then eject. If there isn't, there isn't likely to be a disk in the drive. This is simple, but has a flaw. If your drive is a cdrw, it won't eject if there's a blank disk in the drive. To overcome this flaw, you need to know a little more about how cd drives work, and then it becomes one of those "if you know this much, you wouldn't be posting this question" kind of things. Then again, you won't typically need a supermount function for a blank disk.
For the simple version, just grep 'df' for '/dev/cdrom' or whatever your device is, and place the result into a variable. Test it to see if it's 'true' or not. If you get no result (no /dev/cdrom in df list), it will be false, any mounted cdrom will return true.
One caveat: Some oddball scripting languages invert true and false (t=0/null, false=anything else). If you're using one of them, you probably already know this, though.
|
|
|
04-07-2004, 08:30 AM
|
#3
|
Member
Registered: Aug 2003
Location: Lewisville, TX
Distribution: Kubuntu
Posts: 295
Original Poster
Rep:
|
Yep I know about the true/false issue, lol.
I code in PHP, so not to sound incompetent or anything, but what exactly is the code for what you are talking about?
Code:
$cd = grep | df /dev/cdrom
if ($cd = 0) umount /mnt/cdrom
eject
else eject -t
mount /mnt/cdrom
fi
As you can see, I don't code in shell, LOL! So yea, if you could just edit that code or just give me the working one, that would be good. Oh, anything for grabbing the process ID and killing it?
Thanks so much!
|
|
|
All times are GMT -5. The time now is 06:47 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|