Re: Matching long strings doesn't work



zwenneh@xxxxxxxxxxx wrote:
I'm working on a program that has a command line. Now the users of this
program have requested that we extend the command line to support
longer commands, ie go from 1024 to 16K characters. My problem is that
when I write Expect scripts to perform automated tests, the scripts
fail to send commands of that length.
There's nothing wrong with the program I'm testing, I've tested it
quite a lot (manually, you can imagine), but of course I want the
Expect tests to work.

Below here is one version of the script I'm testing. I'm telnetting
into another computer, and on that computer I run the command-line
program ncli. I then try to verify that it echoes what I enter, but the
problem is that it doesn't: It seems to have a problem sending more
than 1000 chars _into_ the program/prompt, hence what is echoed is not
the full string, and the test times out. I've tried to use "slow
sending", and that helps me increase the number of chars to ~2500, but
it seems to stop there. As I said, there is no problem to enter 16K
chars manually, so there is something wrong with either Expect, the
Unix shell, or something else.

Has anybody encountered problems similar to this?

# script begins
#!/vobs/cello/cade_struct/bin/expect -f

# Author Sven

# I usually telnet to the same computer, but I can change if I want to.

if {[llength $argv] == 0 } { set ip "134.138.83.39" }
if {[llength $argv] == 1 } { set ip $argv }

# set up super long string to send, just lots of t's.

set longString ""
for { set i 0 } { $i < 16383 } { incr i } {
set longString "t$longString"
}

set passed 0

# logging in to the node

spawn telnet $ip

expect "username:"
send "x\r"
expect "password:"
send "x\r"
expect "Welcome"
expect "$"

# start ncli

send "ncli\r"
expect ">"

match_max 131072 # just to be on the safe side
send $longString"\r"

expect "NOT ACCEPTED" {set passed 1}

if { $passed == 0} { puts "Test Failed" }
if { $passed ==1 } { puts "Test OK" }

# exit ncli, then close the telnet connection
send "exit\r"
send "exit\r"

# script ends


I know you tried send slow but the parameters you enter are very important. Try:

set send_slow {1 .01}

and see if that helps. Make sure you set send_slow locally. I've done a lot of expecting with telnet and have found that many receiving devices act really strange if you try to send too fast. If that doesn't help try:

set send_slow {1 .1}

It's going to take a long time to send out 16K characters but give it a shot.

Btw, match_max will only affect your matching not the sending business.

Robert Joy

.



Relevant Pages

  • Re: Expect scripting
    ... ,then the script would telnet to and login then transfer control back ... script file is capturing the shell cmd line and the commands are never ... sent to the telnet session. ... expect "COMPL" ...
    (comp.lang.tcl)
  • Re: Expect scripting
    ... is that if the command is entered with the arguements ... ,then the script would telnet to and login then transfer control back ... script file is capturing the shell cmd line and the commands are never ... sent to the telnet session. ...
    (comp.lang.tcl)
  • Re: send command
    ... It's a shell script that comes with Expect. ... the command line and starts recording everything you type: telnet, ... -- everything you do is recorded as a series of expect/send commands. ... Connection closed.\r ...
    (comp.lang.tcl)
  • UPDATE: Keeping Telnet Session Open
    ... even tell script what commands to run in a non-interactive, ... see the telnet running in the psoutput. ... the other end is accepting the connection. ...
    (SunManagers)
  • Re: Converting using a hash
    ... > I recently wrote a Perl script to convert 8-bit characters to LaTeX ... > Now I tried to use a hash instead of consecutive replacement commands. ... Perl cannot interpolate variable names like $enctabelle. ...
    (perl.beginners)