Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/expect -f
- #set variables
- set hostname ...
- set username..
- set ip ...
- foreach hostname [array names interface] {
- set timeout 10
- match_max 500000
- # Log results
- log_file -a ~/results.log
- send_user "n"
- send_user ">>>> Working on $hostname @ [exec date]<<<< n"
- send_user "n"
- #ssh
- spawn ssh -2 -o strictHostKeyChecking=no $username@$ipaddress
- expect "username:"
- send "$usernamer"
- expect "#"
- expect "password:"
- send "$passwordr"
- expect -re $prompt
- #enable configure mode
- send "conf tn"
- expect "(config#)"
- #vlan trunking mode
- send "$interface($hostname)n"
- expect "(config-if-range)#"
- send "switchport access vlan 9n"
- expect "(config-if-range)#"
- send "switchport trunk encapsulation dot1qn"
- expect "(config-if-range)#"
- send "switchport mode trunkn"
- expect "(config-if-range)#"
- send "switchport trunk allowed vlan 7n"
- expect "(config-if-range)#"
- send "endn"
- expect "#"
- send "write memn"
- expect "#"
- send "terminal length 0r"
- expect "#"
- send "show running-configr"
- expect "#"
- }
- set output $expect_out(buffer)
- puts "$output"
- #Here dont working
- puts -nonewline "Are you sure configuration is finished?(Y/n):"
- set res [read stdin 1]
- if { $res != "y" && $res != "Y" } {send_user -- "write memn"}
- }
- else { exp_continue
- }
- expect eof
- exit
Add Comment
Please, Sign In to add comment