LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 03: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, 09: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, 09:34 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

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

Rgds
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:42 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
Open Source Consulting | Domain Registration