Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to send enable password using expect i have written my code but having some issues in it .


proc clearLine { conServerIp} {
set password "lab"
set enablepw "lab"
set spwnid [ spawn telnet $conServerIp]
expect {
"Password:" {
send $password\r
set flag 1
}
}

send "enable\r"
expect -re ".*:"
send $enablepw\r
expect -re "SAT-RP-TS#"
send "show users\r"
puts $expect_out(buffer)

}



O/P:
spawn telnet <ip>
Trying <ip>...
Connected to <ip>.
Escape character is '^]'.


User Access Verification

Password:
hostname >enable
Password:
hostname #
hostname #

Script abruptly stops here without continuing to execute show users
please help why it is happening and how to avoid it?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900