delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/12/27/18:36:28

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 27 Dec 2001 17:36:08 -0600 (CST)
From: Bradley Holdridge <Bradley DOT Holdridge AT motorola DOT com>
X-Sender: holdridg AT scotty
To: Cygwin Mailing List <cygwin AT cygwin DOT com>
Subject: Expect hanging on long "send" commands
Message-ID: <Pine.GSU.4.21.0112271707140.19457-100000@scotty>
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019