Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-22-2004, 01:52 PM   #1
LQ Newbie
Registered: Oct 2003
Location: warsaw
Distribution: Own ;)
Posts: 22

Rep: Reputation: 15
Checking if a device is mounted using a script


i would like to write a script which does the following actions:
1. In case the cdrom is mounted, unmount and eject it.
2. In case it isn't mount it.

Now I have these simple questions:
How do I check if a device is mounted?
How do I eject a cd?

Old 02-22-2004, 02:07 PM   #2
LQ Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,661

Rep: Reputation: 229Reputation: 229Reputation: 229
"How do I check if a device is mounted?"

Use the mount command without any parameters to give you a list of all mounted devices and search the output using grep:
mount | grep (grep parameters)
if test $? -eq 0;

"How do I eject a cd?"
Use the eject command.

Be prepared. Create a LifeBoat CD.

Steve Stites
Old 02-22-2004, 03:17 PM   #3
LQ Newbie
Registered: Oct 2003
Location: warsaw
Distribution: Own ;)
Posts: 22

Original Poster
Rep: Reputation: 15
big thanks.


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
swap device not getting mounted jacobselvin Linux - Newbie 9 07-20-2005 09:48 AM
Checking device status neerukamra Linux - General 1 09-06-2004 01:12 AM
script check to see if device is mounted Warmduvet Programming 14 09-03-2004 06:17 PM
Checking a USB Device extremebfn Linux - Wireless Networking 2 07-30-2004 08:26 PM
Mounted Device names Rodzilla Linux - Newbie 7 09-25-2003 10:39 AM

All times are GMT -5. The time now is 12:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration