I have corrected the code line and now I just need to dump information to a data file text. I set the output option to open "ASR $ now.txt" "w" but I'm still getting an error. What information do I need to work?
#!/usr/bin/expect -f
set timeout -1
spawn $env(SHELL)
match_max 100000
expect -exact "use@home:~\$ "
send -- "telnet xxx.xxx.xxx.xxx"
expect -exact "telnet xxx.xxx.xxx.xxx"
send -- "\r"
expect -exact "\r
Trying xxx.xxx.xxx.xxx...\r
Connected to xxx.xxx.xxx.xxx.\r
Escape character is '^\]'.\r
\r
\r
User Access Verification\r
\r
Username: "
send -- "exampleuser"
expect -exact "exampleuser"
send -- "\r"
expect -exact "\r
Password: "
send -- "examplepassword\r"
expect -exact "\r
ROUTERCISCO>"
send -- "enable\r"
expect -exact "enable\r
Password: "
send -- "examplepassword\r"
expect -exact "\r
ROUTERCISCO#"
send -- "terminal length 0"
expect -exact "terminal length 0"
send -- "\r"
expect -exact "\r
ROUTERCISCO#"
send -- "show running-config"
expect -exact "show running-config"
set output [open "/home/redip/new.txt" "a+"]
sleep 2
set outcome $expect_out(buffer)
puts $output $outcome
incr i
close $output
send -- "\r"
expect -exact "\r
!\r
!\r
!\r
!\r
end\r
\r
ROUTERCISCO#"
send -- "exit\r"
expect -exact "exit\r
Connection closed by foreign host.\r
use@home:~\$ "
send -- ""
expect eof
#!/usr/bin/expect -f
set timeout -1
spawn $env(SHELL)
match_max 100000
expect -exact "use@home:~\$ "
send -- "telnet xxx.xxx.xxx.xxx"
expect -exact "telnet xxx.xxx.xxx.xxx"
send -- "\r"
expect -exact "\r
Trying xxx.xxx.xxx.xxx...\r
Connected to xxx.xxx.xxx.xxx.\r
Escape character is '^\]'.\r
\r
\r
User Access Verification\r
\r
Username: "
send -- "exampleuser"
expect -exact "exampleuser"
send -- "\r"
expect -exact "\r
Password: "
send -- "examplepassword\r"
expect -exact "\r
ROUTERCISCO>"
send -- "enable\r"
expect -exact "enable\r
Password: "
send -- "examplepassword\r"
expect -exact "\r
ROUTERCISCO#"
send -- "terminal length 0"
expect -exact "terminal length 0"
send -- "\r"
expect -exact "\r
ROUTERCISCO#"
send -- "show running-config"
expect -exact "show running-config"
set output [open "/home/redip/new.txt" "a+"]
sleep 2
set outcome $expect_out(buffer)
puts $output $outcome
incr i
close $output
send -- "\r"
expect -exact "\r
!\r
!\r
!\r
!\r
end\r
\r
ROUTERCISCO#"
send -- "exit\r"
expect -exact "exit\r
Connection closed by foreign host.\r
use@home:~\$ "
send -- ""
expect eof