· 6 years ago · Jun 26, 2019, 07:56 AM
1liste=(
2192.168.1.1
3192.168.1.2
4192.168.1.3
5192.168.1.4
6192.168.1.6
7192.168.1.7
8192.168.1.8
9192.168.1.50
10192.168.1.11
11192.168.1.12
12192.168.1.13
13192.168.1.15
14192.168.1.16
15192.168.1.17
16192.168.1.18
17192.168.1.21
18192.168.1.22
19192.168.1.23
20192.168.1.25
21)
22
23for host in "${liste[@]}"
24do
25 output=$(expect -c "; spawn ssh admin@${host}; send \"show spantree ports blocking\"; expect \"show spantree ports blocking\"; send \"\r\"; expect \"\r\"; send \"exit\"; expect \"exit\"; send \"\r\"; expect eof")
26 echo "$output" |awk 'NR > 12 && ! /exit/ && ! /Connection/ { sub("-> show spantree ports blocking", "", $0); print $0}'
27done