4
rated 0 times
[
4]
[
0]
/ answers: 1 / hits: 7498
/ 2 Years ago, fri, june 17, 2022, 2:46:54
I'm trying to make a script that takes the product and vendor id printed by using lsusb
, then checking against this ID to find the USB device's directory in /sys/bus/usb/devices
.
I initially thought the Bus and Device number printed by lsusb would point to the appropriate folder. For example, if Bus = 002
and Device = 002
, the USB's directory would be /usb/devices/2-2
. Unfortunately, this turned out to not be the case.
I can manually find the appropriate folder using this command I found in another thread:
for X in /sys/bus/usb/devices/*; do
echo "$X"
cat "$X/idVendor" 2>/dev/null
cat "$X/idProduct" 2>/dev/null
echo
done
However, I need a script that can automate finding this folder.
More From » usb