tigerden
tigerden

Reputation: 728

udev rule not working

I am trying to write a udev rule for USB drive plugin. I want to first mount it to /media and then run the script at /usr/local/bin/script.sh. When I insert the USB, it doesn't even mount the device with this rule. However, If I manually type the part in RUN into terminal, It mounts and executes script.

The rule file says:

ACTION=="add", KERNEL=="sd[a-z]*", RUN+="/bin/mount -t auto /dev/%k /media/ && /usr/local/bin/script.sh"

Is this the right way to execute two commands in RUN section of the rule?

Upvotes: 2

Views: 1451

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798626

/bin/mount doesn't take && as an argument. If you want a shell chain to be executed then you must pass it to a shell.

RUN+="/bin/sh -c '...'"

Upvotes: 1

Related Questions