Wednesday, 21 August 2013

Expect/Exp_Send Only works with two expects in a row

Expect/Exp_Send Only works with two expects in a row

I have an tcl script that is supposed to send a grep command to a server,
but will only execute the command if I put another expect with exp_send
immediately after.
set spawn_id [::SshLibrary::connect **.***.**.*** username password]
;#just ssh, essentially
set cmd "grep \"$str\" /var/log/syslog/$smtsIp"
expect -re $::LinuxLIbrary::prompt { exp_send "$cmd\r"}
expect -re $::LinuxLibrary::prompt { exp_send "echo \" \"\r }
...
So, through experimentation, I've found out that the first expect will
only exp_send its command if the second expect statement is present
(Similarly for the second expect command, regarding the presence of the
first) even though they expect the same thing and the second statement is
entirely useless. I'm unsure of what the problem is, it seems totally
illogical. Any suggestions?

No comments:

Post a Comment