Add expect variable

Asked

Viewed 190 times

0

I would like to create a shell script connecting on the controller SPECK to insert the macAddres of customers, using expect, I really need to create a script to automate the process.

Variables mac_desired ,Description

control

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"

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"
  • Andre does not use the Answer field to make an "edit of your question". Copy the code and edit your original question!

  • Hello, I closed the question, researched and did some more tests and it worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.