Feb-05-2018, 12:31 PM
Hi All,
I have below script to telnet devices and gather MAC details with noappend mode and storing in file. I would like to convert this to python script.
##########
#log_user 0
set timeout 10
set f [open "UT-ROM-Batch-1.txt"]
set hosts [split [read -nonewline $f] "\n"]
log_file
foreach host $hosts {
spawn telnet $host
expect {
"Login:" {
}
timeout {
continue
}
}
send "admin\r"
expect "Password:"
send "1234\r"
expect "Alfran1>"
send "dsl -c\r" # Prompt change
expect "\\$" # New prompt
log_file -noappend /home/anna/scripts/ut/$host.umac
send "get bridge port forwarding\r"
expect "\\$"
send "\x1A" # Send control+z to come out from inner prompt
expect "Alfran1>" # Outer prompt
send "exit\r"
log_file
}
expect eof
close $f
I have below script to telnet devices and gather MAC details with noappend mode and storing in file. I would like to convert this to python script.
##########
#log_user 0
set timeout 10
set f [open "UT-ROM-Batch-1.txt"]
set hosts [split [read -nonewline $f] "\n"]
log_file
foreach host $hosts {
spawn telnet $host
expect {
"Login:" {
}
timeout {
continue
}
}
send "admin\r"
expect "Password:"
send "1234\r"
expect "Alfran1>"
send "dsl -c\r" # Prompt change
expect "\\$" # New prompt
log_file -noappend /home/anna/scripts/ut/$host.umac
send "get bridge port forwarding\r"
expect "\\$"
send "\x1A" # Send control+z to come out from inner prompt
expect "Alfran1>" # Outer prompt
send "exit\r"
log_file
}
expect eof
close $f