Add variable expect

0

I would like to create a script shell that connects to the CISCO controller to insert the macAddres clients, using expect >, I actually need to create a script to automate the process.

Variables mac_description, description

controller command

config macfilter add mac_desejado 0 management "descrição"

#!/usr/bin/expect -f
spawn ssh -l andre 11.111.11.1
expect "password: "
send "PASSWORD\r"
expect "ls\r"
send "exit\r"
    
asked by anonymous 27.03.2018 / 02:41

1 answer

0
~#!/usr/bin/expect
set timeout 20
set ip [lindex $argv 0]
set mac [lindex $argv 1]
set desc [lindex $argv 2]



spawn telnet $ip

expect "User:"
send "user\r"

expect "Password:"
send "password\r"


expect ">"
send "config macfilter add $mac 0 management \"$desc\"\r"
expect ">"
send "save config\r"
expect "n)"
send "y\r"
expect ">"
send "exit\r"
    
27.03.2018 / 19:08