0

This question already has an answer here:

I am working on an application which deals with all kinds of USB storage devices(such as taking backup, updating DataLogFile etc)

My problem is :

I want to write a shell script which is stored in this USB drive(As usb is at center of my project so USB is going to be same but PC's will change) AND this script should be executed as soon as the USB drive is connected to my Linux system.I will not need any kind of "root" or "sudo" permissions for other tasks which I am going to do in this shell script.

marked as duplicate by Radu Rădeanu, karel, Warren Hill, Eric Carvalho, Aditya Oct 24 '13 at 12:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • But in that question the script is stored on computer ..I want to store it on That "USB DRIVE". – Null pointer Oct 24 '13 at 2:32
  • 2
    You will need to put something on the computer, because for good security reasons Ubuntu will not automatically run a script on the USB stick unless you add a rule akin to the one in the link to compel it to do so. – chronitis Oct 24 '13 at 8:20
1

Use the udev rules described in the other question to run a local script. The local script can look for a file on the newly-mounted device and execute it.

(That's kind of risky for security if you think about it.)

  • Thanks for the answer!But this means I can not make it completely USB dependent..I have to make some changes in my PC? – Null pointer Oct 24 '13 at 9:27
  • Correct. Ubuntu by default will not automatically run scripts off a USB device. You will need to configure it to do so. – poolie Oct 24 '13 at 9:39
  • Okay..Anyway Thanks a lot! I will try your solution! – Null pointer Oct 24 '13 at 16:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.