EXPECT - Show-VLAN-ID Cisco.expect.sh: Difference between revisions
From IT-Arts.net
Created page with "Category:Post-It <nowiki> #!/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..." |
m Text replacement - "Category:Post-It" to "Category:Wiki" |
||
| Line 1: | Line 1: | ||
[[Category: | [[Category:Wiki]] | ||
<nowiki> | <nowiki> | ||
Revision as of 17:53, 8 December 2025
#!/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
