LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-24-2005, 10:50 AM   #1
Imyourdaddy
LQ Newbie
 
Registered: Oct 2005
Location: Vienna
Distribution: suse 9.3, debian
Posts: 3

Rep: Reputation: 0
Question How can I start a programm when a USB device is hotplugged??


Hi!
I wrote a C-server which communicates with a USB/HID device. now i want that this C-program starts every time I plug on the right device. I tried it out using udev but this was not very useful because if I start a process it has to be killed first for going on to create a device knode.
If I unplug it would be great if the c-prozess is killed.



But how could i realise that???

My rule in 10-local.rules located in /etc/udev/rules.d/ looks like this:

BUS="usb", SYSFS{serial}="1.0.0", NAME="usb/%k", SYMLINK="usb/Moeller_HID_GW", PROGRAM="/usr/bin/hello.sh"

(it is just a call of a helloworld.c with a sleep(20) for debugging...)

The funny thing is, if I try it to debug with "udevtest" the programm might be started/because the node-creating process stopps for 20 seconds but it doesn't print out "Hello World"...

I am working on a stable Debian and i have no idea why it doesn't work.

Is that also possible to realise that somewhere in /etc/hotplug????


Greetings!!!!!
 
Old 11-24-2005, 01:31 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
where do you expect "hello" to be printed? certainly it's not going to be in your current terminal window or anything, udev has no bearing on your own login and no right to print messages to terminals all owver the place. instead i'd assume that it'd go off to syslog, so may well popup in /var/log/messages.
 
Old 11-24-2005, 01:46 PM   #3
Imyourdaddy
LQ Newbie
 
Registered: Oct 2005
Location: Vienna
Distribution: suse 9.3, debian
Posts: 3

Original Poster
Rep: Reputation: 0
Yes, I knew that "hello" is not posted, but my main question is another...and in var/log/messages is it also not printed, if you mean that?

How can I realise that the process is started when I plug the device and it is killed if I unplug it????

What do you mean with using syslog and syslog.conf? How does that work???

greetings
 
Old 11-24-2005, 03:27 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well you'd use a mechanism that IS visible. you can use zenity from gnome to pop up a message on a predefined X server etc...
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
To get notified about a USB device getting Hotplugged Amol Patki Programming 2 04-06-2005 03:12 PM
Hotplugged device names mserms SUSE / openSUSE 1 12-16-2004 09:22 AM
Removing Hotplugged USB drive parados SUSE / openSUSE 1 10-18-2004 11:56 AM
How to make a programm to start at the end of startup process ayachi Linux - Software 1 04-15-2004 10:31 AM
blackbox start programm on startup ichbinesderelch Linux - General 2 12-15-2002 08:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:21 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