[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: udev rule writing help needed



Hi Graham,

On Mon, 11 Jun 2007, Graham Evans wrote:

On Sun, 10 Jun 2007 19:30:16 +0200, Don Hayward wrote:


---snip

So my questions are:
1) what string substitution do I use to get the needed bit into my
command? 2) do I need quoting in the rule?
3) can this work anyway?

Thanks for any help.

Don

I have found the rules easy to write and writing the executables called
tricky.  This following is a kludge: with probably some over the top and
uneccessary parts.  It is adapted from a udev triggered script I use to
get my scripts to run in xterminals - perhaps that will help your script
to work.  And perhaps someone here can help clean it up.

First put your line in a script (I am assuming you need to run the
command as root - in which case you will need to set up sudo to work for
this...):

#!/bin/bash
sudo echo 1 > /sys/class/scsi_disk/14\:0\:0\:0/allow_restart
#Delete the following 2 lines once everything is working
echo 'udev executed script finished: Press enter.'
read ARG

The effect of the last two lines is to give you a chance to see any
relevant output for troubleshooting.  Call the script, say,
scsiScriptForUdev.  Test it, make it executable and save it in /usr/
bin/...

#!/bin/bash
if [ "$ACTION" != 'add' ] ; then
exit
fi
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
LocalDisplay=':0'
X11User=`who | grep $LocalDisplay | sed -n 1p | cut -f 1 -d ' '`
Command='sudo xterm -e scsiScriptForUdev'
export DISPLAY=$LocalDisplay
nice -n 19 su $X11User -c "$Command &> /tmp/udevScriptErrorOutput.txt" &

Seems crazy and I am sure there is a neater way to do it - but perhaps
with the xterm output and the output in the /tmp/ text file you will have
more information to work with.

If you do manage to get it working and/or optimise it let us know.

Graham



Thanks for the good ideas.  There seems to be something else going on.
I tried triggering a script to just echo into a file, but I'm not
getting output--so it seems my program isn't running.

I'm also seeing this in daemon.log:

Jun 14 13:20:32 chloropus udevd-event[5427]: wait_for_sysfs: waiting for '/sys/devices/pci0000:00/0000:00:06.0/0000:02:0b.2/usb5/5-3/5-3:1.0/host4/target4:0:0/4:0:0:0/ioerr_cnt' failed

which may be a red herring, but I wonder if something is not letting
the insertion process complete -- so my script never gets triggered.

Thanks again for you help.

Don

--
Don.Hayward at pomobuli.net -- debian/rules -- Registered Linux user #374806
- History is the best antidote to illusions of omnipotence and omniscience.
- It should forever remind us of the limitations of our passing perspectives.
- It should strengthen us to resist the pressure to convert momentary
-   interests into moral absolutes. -- Arthur Schlesinger Jr.



Reply to: