This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Expect hanging on long "send" commands


I'm working on an SNMP agent and have written an expect script to
simplify using the test SNMP manager provided by our vendor. However,
I ran into problems whenever the "send" string was long (to avoid any
proprietary issues, I've sanitized the names of the command and the
variables, but the length of each one is the same):

    -re "^ *cmdName +(.+) +(.+) +(.+) +(\[0-9]+) *\[\n\r]+" {
       send "set aaaaaaaaaaaaaaaaa.0 $s\
                 bbbbbbbbbbbbbbbbbbbb.0 $c\
                 cccccccccccccccccc.0 $j\
                 ddddddddddddd.0 1\
                 eeeeeeeeeeeeeeee.0 \"$expect_out(1,string)\"\
                 ffffffffffffff.0 \"$expect_out(2,string)\"\
                 ggggggggg.0 \"$expect_out(3,string)\"\
                 hhhhhhhhhhhhhhhhhhhhhhhhhh.0 $expect_out(4,string)\r"
       dump_output
    }

Then the script would just hang and never come back. Using
"exp_internal 1" provided this information:

send: sending "set aaaaaaaaaaaaaaaaa.0 101 bbbbbbbbbbbbbbbbbbbb.0 11 ccccccccccc
ccccccc.0 1 ddddddddddddd.0 1 eeeeeeeeeeeeeeee.0 "A" ffffffffffffff.0 "B" gggggg
ggg.0 "C" hhhhhhhhhhhhhhhhhhhhhhhhhh.0 1\r" to { 4

I verified that the test manager's input buffer was big enough and
that the "set" command succeeded if entered into the test manager
running outside of expect. I then verified that the command succeeded
under expect if entered in manually using the "interact" command.
After further experimentation, I discovered that the command would
succeed if I added the following kludge:

    -re "^ *cmdName +(.+) +(.+) +(.+) +(\[0-9]+) *\[\n\r]+" {
       send "set aaaaaaaaaaaaaaaaa.0 $s\
                 bbbbbbbbbbbbbbbbbbbb.0 $c\
                 cccccccccccccccccc.0 $j\
                 ddddddddddddd.0 1\
                 eeeeeeeeeeeeeeee.0 \"$expect_out(1,string)\""

                 send_user "...Press <Enter>..."
                 expect_user -re ".*\[\r\n]+"

       send "    ffffffffffffff.0 \"$expect_out(2,string)\"\
                 ggggggggg.0 \"$expect_out(3,string)\"\
                 hhhhhhhhhhhhhhhhhhhhhhhhhh.0 $expect_out(4,string)\r"
       dump_output
    }

The longest "set" command in the script had to be broken up into four
chunks (three user prompts) to work reliably.

A severely pruned version of my "cygcheck" dump:

Windows NT Ver 4.0 Build 1381 Service Pack 6

Cygwin DLL version info:
    DLL version: 1.3.6
    Build date: Sat Dec 8 17:02:30 EST 2001

Package             Version             
expect              20010117-1          
tcltk               20001125-1          

This issue isn't critical for me, since I've found a workaround. I
just thought I'd let you know. Thanks.

-- 
Bradley Holdridge


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]