#!/bin/bash

UDEVADM=/sbin/udevadm
if [ -f ${UDEVADM} ]; then
    busid=`lsusb | grep 043d: | awk '{print $2 ":" $4}'`
    for item in $busid
    do
        bus=`echo $item | awk -F: '{print $1}'`
        dev=`echo $item | awk -F: '{print $2}'`
        lnk=`${UDEVADM} info -q path -n /dev/bus/usb/$bus/$dev`
        pro=`${UDEVADM} info -a -p $lnk | grep 'ATTR{product}==' | sed 's/ATTR{product}==//g' | awk -F\" '{print $2}'`
        mfg=`${UDEVADM} info -a -p $lnk | grep 'ATTR{manufacturer}==' | sed 's/ATTR{manufacturer}==//g' | awk -F\" '{print $2}'`
        ser=`${UDEVADM} info -a -p $lnk | grep 'ATTR{serial}==' | sed 's/ATTR{serial}==//g' | awk -F\" '{print $2}'`
        escpro=`echo $pro | sed 's/ /%20/g'`
        echo "$bus:$dev;$mfg $pro;usb://$mfg/$escpro?serial=$ser"
    done
fi
