The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using FireWire 400 peripherals with multimedia applications and FireWire 800 ports iBot OS X Support RSS 0 04-26-2009 03:30 AM
Sun Ray Peripherals/Third Party Component List iBot Solaris BigAdmin RSS 0 04-21-2009 08:15 PM
How to detect whethere the CD is R or RW jisha Shell Programming and Scripting 2 07-24-2008 01:03 PM
mont of peripherals selim High Level Programming 0 02-22-2005 08:57 AM
How can I map Unix keyboard for PC keyboard simhab UNIX for Advanced & Expert Users 1 03-06-2002 11:29 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-04-2009
chebarbudo's Avatar
chebarbudo chebarbudo is offline
Registered User
  
 

Join Date: Nov 2008
Location: various
Posts: 188
Question Detect USB keyboard and other peripherals

Hi there,

I have a Debian machine without any peripherals (no screen, no keyboard, etc.). I'd like to be able to detect and log when someone plugs a USB keyboard. Something like : 2009-07-04 12:21 warning: keyboard pluged!
Is that possible?

I see two ways :
1. Either actively react to the connection of a device and execute a script that logs the alert.
2. Or cron a script that checks for USB devices every 5 minutes.
I have no idea how to do either ways.
Can anyone help me on that?

I would be glad to just be able to alert when any USB device is plugged. No matter if it's a keyboard or a flash key. But if I can make the difference between each device type... Better!


Thanks for your help
Santiago
  #2 (permalink)  
Old 07-04-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 730
The obvious idea that comes to mind is to watch for messages from dmesg (or the /var/adm/messages file?) as USB devices are plugged in, it is how I normally find out what the device path for a USB stick is anyway...
  #3 (permalink)  
Old 07-06-2009
chebarbudo's Avatar
chebarbudo chebarbudo is offline
Registered User
  
 

Join Date: Nov 2008
Location: various
Posts: 188
Thanks TonyFullerMalv,
I'm investigating this idea.
Though, I have no such /var/adm/ folder.
  #4 (permalink)  
Old 07-06-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 730
Quote:
Originally Posted by chebarbudo View Post
Thanks TonyFullerMalv,
I'm investigating this idea.
Though, I have no such /var/adm/ folder.
Sorry I was thinking Solaris! Try looking in /var/log/messages!

Also try taking a look at the lsusb(8) command.
  #5 (permalink)  
Old 07-06-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,866
Depending on how current your Debian installation is you might have DBUS & HAL installed. There's a command-line tool for DBUS which you can instruct to listen for added devices: (example is a flash drive)
Code:
> dbus-monitor --system --profile 'interface=org.freedesktop.Hal.Manager, member=DeviceAdded'
sig     1246865406      537113  2       /org/freedesktop/DBus   org.freedesktop.DBus    NameAcquired
sig     1246865413      849690  6387    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865413      898142  6390    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865414      883198  6393    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865414      883255  6394    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865414      903331  6403    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865415      53744   6430    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865415      97264   6449    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
If you pipe this into a loop you should be able to detect just about any HW change.
Reply

Bookmarks

Tags
detection, keyboard, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0