passing arguments to shell script from udev rules file passing arguments to shell script from udev rules file shell shell

passing arguments to shell script from udev rules file


You should be able to use single quotes instead of the double quotes you mentioned:

ACTION=="add", RUN+="/appmount/scripts/usb_mount.sh '%E{ID_FS_LABEL}' '%E{DEVNAME}'"

Beware: I didn't test this. Maybe variable substitution will fail within single quotes...

Quoting from man udev about the key "RUN":

The program name and following arguments are separated by spaces. Single quotes can be used to specify arguments with spaces.


Just set and query udev's env, here an example to check if system is running VMWare :

cat /etc/udev/rules.d/99-vmware.rulesKERNEL=="id", SUBSYSTEM=="dmi", ATTR{sys_vendor}=="VMware, Inc.", ENV{VMWARE}='defined'udevadm info -e  | grep 'VMWARE='E: VMWARE=defined