[已解决]udev规则里%k传的是什么?

最大的社区版本,Ubuntu的发源地
回复
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

[已解决]udev规则里%k传的是什么?

#1

帖子 科学之子 » 2017-11-09 3:30

代码: 全选

# MediaTek MT6276M and others, MediaTek/Medion S4222 and probably others
ATTR{idVendor}=="0e8d", ATTR{idProduct}=="0002", RUN+="usb_modeswitch '/%k'"
#ATTR{idVendor}=="0e8d", ATTR{idProduct}=="0002", RUN+="/home/user/test/test.sh '/%k'"
test.sh收到的参数是"/4-2"

但换成usb_modeswitch 就是类似下面的内容:

代码: 全选

-j -Q -b 4 -g 15 -v 0e8d -p 0002
-Q -D -b 4 -g 15 -v 0e8d -p 0002 -f # MediaTek MT6276M and others TargetVendor=0x0e8d TargetProductList="00a1,00a2,00a5" MessageContent="555342431234567800000000000006f0010300000000000000000000000000"
test,sh和modswitch的内容:

代码: 全选

#!/bin/sh
echo $* >>/usblog
两者并没有收到相同的参数,也没看出两者参数的关系来.

Sun Nov 12 00:26:17 CST 2017补充:
原来那个是/lib/udev/usb_modeswitch,并非PATH变量路径里的usb_modeswitch.
man udev:
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.
上次由 科学之子 在 2017-11-12 0:29,总共编辑 2 次。
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: [已解决]udev规则里%k传的是什么?

#2

帖子 astolia » 2017-11-11 10:37

man -P cat udev | grep -C 1 '%k'
回复