port.sh 620 Bytes
#!/bin/bash

base=`dirname $0`
cd $base
data=$(dmesg | grep ttyACM | cut -f 7 -d " " | cut -f 1 -d : )
code=$(echo $data | cut -f 1 -d " ")
port=$(pwd | cut -c 17)
let port--
dev="/dev/ttyACM"
name="$dev$port"
commande=$(udevadm info --name=$name --attribute-walk | egrep "idVendor|idProduct|serial")
idProduct=$(echo $commande | cut -f 1 -d " ")
idVendor=$(echo $commande | cut -f 2 -d " ")
serial=$(echo $commande | cut -f 3 -d " ")
newdev="ttyPR"
newname="$newdev$port"
rule="SUBSYSTEM==\"tty\", $serial, $idVendor, $idProduct, SYMLINK+=\"$newname\""
echo $rule >> /etc/udev/rules.d/usb-serial.rules
udevadm trigger