Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-24-2012, 08:40 AM   #1
LQ Newbie
Registered: Feb 2012
Posts: 2

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


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, 09:03 AM   #2
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,153

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

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

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


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

All times are GMT -5. The time now is 10:59 PM.

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
Open Source Consulting | Domain Registration