usb怎么驱动怎么编程python_如何在插入USB闪存驱动器时运行Python脚本

RUN{type}

Add a program to the list of programs to be executed after

processing all the rules for a specific event, depending on "type":

"program"

Execute an external program specified as the assigned value. If

no absolute path is given, the program is expected to live in

/lib/udev; otherwise, the absolute path must be specified.

This is the default if no type is specified.

"builtin"

As program, but use one of the built-in programs rather than an

external one.

The program name and following arguments are separated by spaces.

Single quotes can be used to specify arguments with spaces.

This can only be used for very short-running foreground tasks.

Running an event process for a long period of time may block all

further events for this or a dependent device.

Starting daemons or other long-running processes is not appropriate

for udev; the forked processes, detached or not, will be

unconditionally killed after the event handling has finished.

在udev手册页中,请特别注意最后两段。

我猜,你已经发现了无条件杀戮的部分

1年后编辑:

在有人投票通过后,我重新讨论了这个问题,这些问题是,root(谁在运行这个进程)没有一个X终端条目,对于某些事情,比如notify-send或启动一个Gui程序,仍然存在进程被杀死的情况,如前所述。

当插入usb设备时,下面的命令向终端发送通知并启动wxpythongui程序。在

剧本:

^{pr2}$

通过定义DISPLAY,我们可以解决root用户的no X term entry问题

通过将要运行的命令传递给at程序,并使用立即运行它的指令,我们可以避免udev杀死进程。在

/lib/udev/rules.d/10-usbinsert.规则文件:KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/usr/bin/sudo -u rolf /home/rolf/script.sh &"

我希望这能帮助你或者让你朝着正确的方向前进。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值