Review your favorite Linux distribution.
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, 07: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, 08:03 AM   #2
Registered: Aug 2005
Location: Brazil
Distribution: Debian Jessie
Posts: 829

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

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

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 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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration