LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-05-2008, 04:14 AM   #1
linux1
LQ Newbie
 
Registered: Jun 2008
Posts: 4

Rep: Reputation: 0
How to detect wheather usb drive is connected thru script


Hi,

is there any way to detect usb drive through a script.
A script which will do polling , to detect usb drive.

Thanks in Advance
 
Old 06-05-2008, 10:14 AM   #2
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Don't quite understand and am not scripting pundit, however:

When a USB drive is plugged in a unique names for it appear somewhere in the /dev directory (assuming you are running udev or whatever it is called). So, for example, there will be a long name for the thing in /dev/disk/by-id. So how about writing a script that simply tests for that name being present?
 
Old 06-05-2008, 10:34 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
Try this command in a terminal : 'lsusb'

Rgds
 
  


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 detect usb devices connected to the system vijaya_svk Linux - Software 5 03-16-2008 03:21 PM
What is the best way to detect a hard drive in a shell script? Mahonri Programming 1 06-14-2007 02:14 AM
Installing Suse 10 on USB drive connected to Thinkpad Z60M alaa53 Linux - Hardware 0 02-19-2006 08:45 AM
Bash Script to Detect USB drive mount status nutthick Programming 6 02-02-2005 09:17 AM
How to open external hard drive when connected to USB??? kingslax Linux - Hardware 1 09-22-2004 07:07 PM


All times are GMT -5. The time now is 04:40 AM.

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