August 7, 201312 yr Hi I have a question for the real linux gurus around here. I want to reset an usb device in my go script. I compiled usbreset.c and it works quite well. Now I need to know the Bus and Device Number of the usb device to feed into the usbreset script. I have lsusb installed so there is no problem to manually get that information. But I think this can be done automatically? lsusb: Bus 001 Device 002: ID 8564:1000 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 003: ID 0ccd:0097 TerraTec Electronic GmbH Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub How can I extract the Bus and Device from the first "TerraTec Electronic GmbH" device and feed it into the second one? /boot/usbreset /dev/bus/usb/002/003 Thanks in advance! edit: I got to this point: lsusb | awk '{print "/dev/bus/usb/"$2"/"$4}' (with later exchanging print with /boot/usbreset) But this gives me every usb device and I still have the colon at the end :-(
August 7, 201312 yr Try this: /boot/usbreset /dev/bus/usb/`lsusb|sed -n "/0ccd:0097/s/^Bus \(0..\) Device \(0..\).*$/\1\/\2/p"` [Note that the (hexadecimal) <Mnfr:Devc> string is unique to the device you are interested in; whereas you might just have more than one "TerraTec ..."-described device. So that is how we select the line to process.] --UhClem
Archived
This topic is now archived and is closed to further replies.