Author Topic: [SOLVED]: Execute a shell script automatically on USB device plugin  (Read 395 times)

Offline AnotherUser

  • Full Member
  • ***
  • Posts: 92
Re: [SOLVED]: Execute a shell script automatically on USB device plugin
« Reply #15 on: January 13, 2013, 03:17:27 PM »
In case anyone comes up with a reason that only some commands within the script run when it is called from a udev rule, maybe you will post it here.

I have now tried the following script, called when the rule is triggered ...

Code: [Select]
#!/bin/bash
zenity --info --text " Hello Homey "
echo Hello Homey >/home/user/q

The result is that /home/user/q gets written to but Zenity is not launched.
Naturally when running the script from a terminal both commands are executed.

So the question is .....  why one command is executed and the other not?

Thanks for any feedback  ;)

My guess is that zenity, being a graphical tool, requires the DISPLAY environment to be set. Since UDEV runs from the equivalent of a console, the shell spawned by UDEV also doesn't have that environment variable set, hence no popup.

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10628
  • MLUs Forever!
Re: [SOLVED]: Execute a shell script automatically on USB device plugin
« Reply #16 on: January 13, 2013, 03:55:11 PM »
Thanks .......  will look into that tomorrow

MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT