Auto-run script when Wifi card is plugged in (udev)

I had a similiar problem a while ago and the solution was to change the RUN+= part to RUN+="sh -c '/root/test.sh'". Now, I don't know if you need that in this case as the rule is calling a script, not a command.

Another observation: try removing the ! from the "test!" string or replace the double-quotes with single quotes. The bang ! is probably making trouble because of its special meaning in the shell and the double quotes preserves that meaning.


My advise would be to set the logging priority of udev from err to info with

 udevadm control --log-priority=info

If you would like to see even more information set it to debug. Now you can find very detailed information of what udev did in /var/log/daemon.log (At least on a debian related system). Generally that helps a lot chasing errors.

This is only a complement to htor's answer which probably solve your problem.