From: "J. Bakshi" <j.bakshi@unlimitedmail.org>
To: linux-hotplug@vger.kernel.org
Subject: problem executing command substitution from udev rules
Date: Tue, 02 Nov 2010 06:46:51 +0000 [thread overview]
Message-ID: <201011020634.oA26Y57h004184@dcnode-01.unlimitedmail.net> (raw)
Hello llist,
I am using notify-send in my udev rules to send desktop notification. Here is the actual command which is working fine for me, even from the root shell.
````````````
/bin/su `ps aux | grep startx | grep '/bin/sh' | awk '{print $1}'` -c "DISPLAY=:0.0 notify-send "test"
`````````````
the part [ ps aux | grep startx | grep '/bin/sh' | awk '{print $1}' ] is for collecting the user-name who is running startx.
now in my udev rule if I hard-coded the user name like
```````````````
ACTION="add", SUBSYSTEM="input", ENV{ID_CLASS}="mouse", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user1/.Xauthority" RUN+="/bin/su user1 -c "DISPLAY=:0.0 notify-send "test" "
``````````````````````````
it works well. But if I try to add command substitution ( with in back-qoutes ) to dynamically collect the user name , it stops working. The rule is like
```````````````
ACTION="add", SUBSYSTEM="input", ENV{ID_CLASS}="mouse", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user1/.Xauthority" RUN+="/bin/su `ps aux | grep startx | grep '/bin/sh' | awk '{print $1}'` -c "DISPLAY=:0.0 notify-send "test" "
``````````````````````````
Definitely I have user1 who is using startx here. Surely the command substitution with in udev rules is not working at all. Can't understand why it fails. I would be grateful if any one point out what is missing/wrong here.
Thanks
next reply other threads:[~2010-11-02 6:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-02 6:46 J. Bakshi [this message]
2010-11-02 9:51 ` problem executing command substitution from udev rules Andrey Borzenkov
2010-11-02 11:49 ` J. Bakshi
2010-11-03 13:17 ` Dan Nicholson
2010-11-03 15:50 ` J. Bakshi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201011020634.oA26Y57h004184@dcnode-01.unlimitedmail.net \
--to=j.bakshi@unlimitedmail.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox