Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to eject my cd from a script running on the CD 2

Status
Not open for further replies.

dans45

Technical User
Feb 13, 2003
43
US
Hello,
I've got a simple linux bash script where I'm installing a couple of rpm files. I'm trying to reboot and eject the cd as well from the same script that is itself on the CD.
I'm unable to eject the cd because "the device is busy".
Is there a simple way around this?
Thanks,
 
no. As long as that script is running and the script is on the CD, the CD device is going to be busy and you aren't going to be able to eject it. (You would be able to eject it after the system boots.)

I suppose you could try adding a second script that copies the script you are running now to /tmp and then kicking off the copied script from the new script. Once the new script kicks the second script, I think the CD device may not be busy any more (as long as you haven't cd'd into the mount point).
 
An alternative might be to place the eject cd part of the script in /etc/rc2.d or wherever, so that it is kicked off when the reboot takes place. HTH.
 
.....but this, of course presupposes that you want the CD drawer to eject every time you reboot.
 
......but there again, if your first script wrote a flag file of some sort, which your /etc/rc2.d script tested for and either opened the drawer if it was there, or didn't if it wasn't (it would need to be deleted by the rc2.d script following the test). Logical eh?

Nurse - the screens!!!!
 
If the "at" daemon is running on the Linux box, you could have your bash script set up a task in that daemon to eject the CD. The bash script could then terminate. Set up the CD eject job to run at a time of "now + 1 minute".

The device wouldn't then be in use, would it?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Alternatively, you could place a proxy script in the computer's /tmp directory, then use exec to transfer control.

# untested
cat >/tmp/ejectit.sh <<EOB
cd /
eject /dev/cdrom
EOB
exec bash /tmp/ejectit.sh
 
thanks for the help!!! I ended up using the proxy script in the /tmp directory suggested by azimuth0(thanks!). I tried the 'at' command but my environment did not have the at demon present.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top