which system runs scripts when USB devices plugged in?
Patrick O'Callaghan
pocallaghan at gmail.com
Wed Nov 10 13:14:00 UTC 2010
On 11/10/2010 04:26 AM, Nick Urbanik wrote:
> Dear Patrick,
>
> On 09/11/10 22:16 -0430, Patrick O'Callaghan wrote:
>> On 11/09/2010 03:44 PM, Nick Urbanik wrote:
>>> Dear Folks,
>>>
>>> I have written a Perl program to copy podcasts onto my iriver device
>>> when it is plugged in. I want to be able to run it automatically.
>>> Which system in Fedora 14 is the most appropriate place to run such a
>>> script from?
>>>
>>> udev? /etc/modprobe.d/*? /sbin/hotplug is not there any more.
>>
>> Udev. Take a look at /etc/udev/rules.d/*
>
> Thank you for that. I am familiar with udev, and was under the
> impression that it is mainly for creating devices and links to devices
> that are predictable.
>
> If udev is the path I should tread for this, then I will do so. But
> is that really the most appropriate place?
I have an /etc/udev/scripts directory on my system that runs some small
scripts when stuff is plugged in (called from the rules entry of
course). I don't know if that's the canonical place but it works and I
know I didn't invent it.
If your script is liable to run for a long time (and it sounds like it
might) you might want to consider splitting it in two, firstly a trigger
which calls the main program asynchronously and returns immediately, and
secondly the main program (which of course can live somewhere else) that
does the actual copying. You'd also need to think about whether the main
program is reentrant (can be run multiple times without finishing) but
you'd need to consider that in any case.
My knowledge of udev is hazy at best, so I don't know if this precaution
is really necessary, but you can have fun programming it :-)
poc
More information about the users
mailing list