LinuxQuestions.org
Review your favorite Linux distribution.
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 02-24-2012, 07:40 AM   #1
rahulpr
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Rep: Reputation: Disabled
Smile how to know a usb is disconnect through a port no


hai,

I had connected a usb in port-no '2' and I have to run the code when the usb is disconnected. How could I know the usb is disconnect using the status of port no in shell script.
 
Old 02-24-2012, 08:03 AM   #2
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
Use the output of the 'lsusb' command.
 
Old 02-24-2012, 08:08 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You could use a udev rule to run a script when the USB device is unplugged.
 
Old 02-24-2012, 08:14 AM   #4
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
Quote:
lsusb | grep -E device
would help
 
  


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
USB keyboard disconnect with ps2/usb converter/splitter eaberry Linux - Hardware 3 01-04-2009 09:52 AM
USB failng after disconnect OpenSourcePaul Linux - Hardware 2 03-21-2007 09:04 AM
disconnect the port connection sunhui Linux - Software 2 02-12-2007 11:25 PM
Unmount when disconnect usb driver jargren SUSE / openSUSE 2 08-17-2006 01:32 PM
Should I unmount usb disk before disconnect? jargren Linux - General 12 08-17-2006 12:14 PM

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

All times are GMT -5. The time now is 08:58 PM.

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