LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 06-27-2009, 05:53 PM   #1
twon
LQ Newbie
 
Registered: Jan 2006
Location: uk
Distribution: Ubuntu 10.10 x86_64
Posts: 14

Rep: Reputation: 0
help with auto run script when usb storage device is plugged in


Hi all

Im wanting to run a script so that every time i plug in a usb storage device it runs a bash shell script. Im not sure how to go about doing this and could do with help.

Thanks

running open suse 11.1 gnome desktop
2.6.27.23-0.1-default SMP x86_64
on HP hdx16 notebook
 
Old 06-28-2009, 03:06 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
If the script is a low-level "config" type thing that should be run as root, then you can use a udev rule to launch it.

If it's a user-level script, then you should be using hal. Probably the easiest way is to use ivman, but I believe it may be possible to set up dedicated policies without it.
 
Old 06-30-2009, 03:44 PM   #3
twon
LQ Newbie
 
Registered: Jan 2006
Location: uk
Distribution: Ubuntu 10.10 x86_64
Posts: 14

Original Poster
Rep: Reputation: 0
i just need to run a simple bash script that is going to call clamav to run a virus scan on the usb drive.

iv written a udev rule: BUS=="usb", SUBSYSTEM=="input", RUN+="/home/twon/scan.sh"
and saved that as file: 80-autorun.rules in /etc/udev/rules.d but i doesnt seem to be doing much
 
Old 06-30-2009, 03:48 PM   #4
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by twon View Post
i just need to run a simple bash script that is going to call clamav to run a virus scan on the usb drive.

iv written a udev rule: BUS=="usb", SUBSYSTEM=="input", RUN+="/home/twon/scan.sh"
and saved that as file: 80-autorun.rules in /etc/udev/rules.d but i doesnt seem to be doing much
I don't think there is enough information here for UDEV to identify the USB device. Also, for a USB storage device, I don't think the SUBSYSTEM should be 'input'

There's a great tutorial on the net (use Google) and also there's one or more here on LQ, which will go a great distance towards showing you how to extract the info you need for a rule, and how to format the rule.

Sasha
 
  


Reply

Tags
auto, usb


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable/enable USB storage device @ run time Mr.J Linux - Security 1 09-08-2008 10:16 AM
[Kubuntu] Which script initializes a USB wireless device once it is plugged in? MonctonJohn Ubuntu 6 08-13-2008 05:43 PM
Auto run a script when connecting a USB device strangeslack Slackware 1 11-16-2007 12:40 PM
Sun Ultra 20 M2 fails to boot if an USB storage device is plugged in crisostomo_enrico Solaris / OpenSolaris 6 08-23-2007 09:16 AM
How to detect programatically if a USB device is is plugged-in / plugged out? franc Linux - Software 3 02-01-2007 04:01 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration