Commit | Line | Data |
---|---|---|
2966005d TM |
1 | #!/bin/bash |
2 | ||
3 | scan_tty() { | |
4 | port="$1" | |
5 | rate="$2" | |
6 | timeout 1 cat < "$port" >/dev/null; | |
7 | stty -F "$port" "$rate" cs8 cread clocal | |
8 | timeout 1 cat < "$port" >/dev/null; | |
9 | ( | |
10 | banner="$(timeout 7 cat < "$port" | tr '\r\n[:cntrl:]' '...' | grep -i '[a-z0-9]' )" | |
11 | [ -n "$banner" ] && echo -e "$port $rate:\t$banner" | |
12 | #echo "$port:$rate:$banner" | |
13 | ) & | |
14 | stty -F "$port" "$rate" cs8 cread clocal | |
15 | sleep 1 | |
16 | #Windows newlines are fore HP ProCurve Switches... | |
17 | #echo -ne '\x03\r\n\x04\x03\r\n\r\n\r\n' > "$port" | |
18 | echo -ne '\x03\r\n\x04\x03' > "$port" | |
19 | sleep 3 | |
20 | echo -ne '\r\n\r\n\r\n' > "$port" | |
21 | wait | |
22 | } | |
23 | ||
24 | printf '\033[?7l' | |
25 | for port in /dev/ttyUSB*; do | |
26 | for rate in 115200 38400; do | |
27 | #echo -ne "\r$port:$rate: " | |
28 | banner="$(scan_tty "$port" "$rate")"; | |
29 | [ -n "$banner" ] && echo "$banner"; | |
30 | echo "$banner" | egrep -i 'linux|root|login|password|user|connect|invalid' >/dev/null && break; | |
31 | done & | |
32 | done; | |
33 | wait | |
34 | printf '\033[?7h' |