expect script doesn't work with the expect c interpreter
I have written the following script and it works like a champ when i run
it through the activesite tclsh command.
However when i run the same script through the expect c interpreter, it
doesn't give me the output. Basically this is a script to read the running
configuration file from a network device and write them into a file. this
is the code
package require Expect
#set ::exp::winnt_debug 1
set prompt "R4#"
set more " --More--"
expect -timeout 10 "$prompt"
set output [open result.txt "w"]
set running 1
spawn plink -telnet "144.21.12.45" -P 2004
send "enable\r"
send "\r"
send "show running-config\r"
send "\r"
while { $running > 0 } {
expect {
"\n" { puts -nonewline $output "$expect_out(buffer)" }
"$more" {send " "}
"lines *-* " { send " " }
#"$prompt" { set running 0 }
eof { set running 0 }
timeout { set running 0 }
}
}
this is the main of the console app through which I call the tcl_eval
(Note that i have removed the error conditions checks to keep it simple)
tcl_interp = Tcl_CreateInterp() ;
Tcl_FindExecutable(arg);
Tcl_Init(tcl_interp);
Expect_Init(tcl_interp);
// pstr contains the script
rc = Tcl_Eval( tcl_interp, pstr ) ;
This would spawn the plink ,but the "show running-config" command is not
shown in the device terminal. The console just shows
Connected to Dynamips VM "R4" (ID 4, type c7200) - Console port
Press ENTER to get the prompt.
©]0;Dynamips(4): R4, Console portE{M'}T
R4#p}
R4#
I suspect that the "send" is not working here. How do I trouble shoot this?
Thanks Sunil
No comments:
Post a Comment