You are not logged in.

#1 2013-11-02 19:03:54

roeleman
Member
Registered: 2007-11-09
Posts: 46

script doesn't work when run by Udev

Hello,

I want to auto rip music cd's when I insert them in my cd-tray.  I wrote a Udev rule for that and the rule does seem to work.

This is my rule:

KERNEL=="sr*", SUBSYSTEMS=="scsi", ENV{ID_CDROM_MEDIA_CD}=="1", RUN{program}+="/usr/bin/cdautoinser"

When I check this with:

udevadm test /sys/block/sr1

Then I can see udev loads the script, but nothing happens.

This is my script, I got it from here: http://jctechnotes.blogspot.com/2012/10 … using.html

#/bin/bash

PATH=/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin /bin/abcde -NVP | tee /var/log/abcde-auto.log &

exit

Can somebody help me what's wrong?

For I forget, I use a usb DVD-drive, but I don't think it matters because udev seems to do what it should do.

Offline

#2 2013-11-02 19:20:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: script doesn't work when run by Udev

Yes, udev does do what it should - but what you want it to do is not what it should do.  Udev rules should not be used like that.  Such invocations tend to fail as udev will kill any child process that continues to run for some time (I don't know the exact threshold, but it's much short than what it takes to rip a cd).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2013-11-02 19:29:04

roeleman
Member
Registered: 2007-11-09
Posts: 46

Re: script doesn't work when run by Udev

That is what I understood reading the manpages.  But if it's not possible this way,  can I let Udev run a small script that kills itself but let abcde do it's job?

Offline

#4 2013-11-02 19:31:14

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: script doesn't work when run by Udev

I'm not sure.  I just went hunting, but couldn't find clear info on this, except that it is not recommended to use udev in this way.

maybe using a `setsid nohup <command> &` invocation would help.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2013-11-02 19:42:56

roeleman
Member
Registered: 2007-11-09
Posts: 46

Re: script doesn't work when run by Udev

Ok, thanks for the tip.  I will try for now.

If I understand it should be better to make a symlink to , for example, /dev/musiccd and let a daemon trace dev for this device.  When it finds it it should execute the abcde.  Am i right?

Offline

#6 2013-11-02 20:31:02

roeleman
Member
Registered: 2007-11-09
Posts: 46

Re: script doesn't work when run by Udev

I found what I was looking for in the arch forum.  udevil & devmon should do the trick.

Thanks for the help, it brought me to a different path.

Offline

Board footer

Powered by FluxBB