Last active
August 29, 2015 13:59
-
-
Save jnelson/10923035 to your computer and use it in GitHub Desktop.
A horribly fragile script to collate identifying information for ttyUSB devices. Ad hoc testing on Ubuntu. Please don't use this unless you agree to: (1) Hold me blameless and harmless for anything that goes wrong, AND (2) Share colorful stories about what went wrong in a comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Reminder: don't use this. | |
candidates=`ls /dev | grep ttyUSB` | |
for targetDevice in $candidates | |
do | |
majMinDevNums=`cat /sys/class/tty/$targetDevice/dev` | |
infoLink=`ls -l /sys/dev/char/$majMinDevNums | awk '{print $NF}' | grep -oP '../../\K.*'` | |
infoDir=`echo /sys/$infoLink | perl -pe "s|(.*)/[\d-:.]+/$targetDevice/.*|\1|"` | |
busnum=`cat $infoDir/busnum` || continue | |
devnum=`cat $infoDir/devnum` || continue | |
echo $targetDevice $majMinDevNums `lsusb -s $busnum:$devnum` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment