Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to execute a shell script when I plug a USB device into my linux box.
I have udev running, and someone mentioned that would be a good place to start, but I don't really know what to do with that info. (the man pages didn't help)
I simply want to plug in a USB drive, and have it execute a shell script, say "/var/myscripts/usb.sh $a"
(where $a is the path to the USB drive, so the shell script could then add files to it, or remove files from it.)
so this just means that if udev picks up a dvb device (this is a string match on the /dev/ entry that udev automatically creates), it runs what's in the PROGRAM variable, aswell as doing other configuration things. you may well find you already have this in your default rules file or an equivalent.
I've modified a few of my udev config/rule files to execute a program, but the program never got executed, I didn't know if there were tutorials anywhere on stuff like this, or maybe what lines to specifically add the PROGRAM= to.
Does anyone know if it is possible to add a catchall for removable storage at the end of one of the rules files? Because I'm just not quite sure how to tell if it is a USB storage device before executing my script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.