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 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: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
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



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

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

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