EXPECT - Show-VLAN-ID Cisco.expect.sh: Difference between revisions
From IT-Arts.net
m Text replacement - "Category:Post-It" to "Category:Wiki" |
m Text replacement - "Category:Wiki" to "Category:Wiki '''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]''''' " |
||
| Line 1: | Line 1: | ||
[[Category:Wiki]] | [[Category:Wiki]] | ||
'''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]''''' | |||
<nowiki> | <nowiki> | ||
Latest revision as of 08:09, 17 January 2026
#!/usr/bin/expect -f
#
#
# SET THE OUTPUT TO NON-BUFFERED MODE FOR "PUTS" COMMAND
fconfigure stdout -buffering none
set timeout 5
set HOST [lindex $argv 0]
set VLAN [lindex $argv 1]
set USERNAME [lindex $argv 2]
set PASSWORD [lindex $argv 3]
# SSH CONNEXION
spawn ssh $USERNAME@$HOST
# spawn ssh -oStrictHostKeyChecking=no -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-dss $USERNAME@$HOST
expect {
"*Are you sure you want to continue connecting*" { send "yes\r" }
}
expect "*assword: "
send "$PASSWORD\r"
expect {
"*>" { exp_continue }
"*#" { exp_continue }
}
# GET THE VLAN
#send "show version\r"
send "show vlan id $VLAN\r"
expect "stby#"
sleep 1
# EXIT
send "exit"
exit 0
