?
Solved

How to Detect the Presence of USB Flash Drive in Linux bash script?

Posted on 2011-05-01
2
Medium Priority
?
2,150 Views
Last Modified: 2012-05-11
Hello,

I'm using Linux Fedora 14 Distro.

I need to detect the presence of a USB flash drive in a bash script and then make one of two choices based on whether it's there or not.

How can I do this?  Specific code is greatly appreciated.

Thanks,
Jason
0
Comment
Question by:SqueezeOJ
2 Comments
 
LVL 3

Accepted Solution

by:
Abhishek_Chib earned 1000 total points
ID: 35500673
0
 

Author Comment

by:SqueezeOJ
ID: 35500900
Thanks Abhishek_Chib!

Here's the code I generated from that link:

if sudo lshw | grep "label=MyUSBDrive" ; then
  echo "Flash Drive Available"
else
  echo "Flash Drive NOT Available"
fi

Open in new window

0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question