Expect : Using a variable length list containing expect regexps?
From: Bob - Andover, MA (tsreyb_at_yahoo.com)
Date: 04/29/04
- Next message: Craig: "Re: dqkit - link problem (almost there though)"
- Previous message: Joi Osoy: "Compiling Tile on Windows"
- Next in thread: Glenn Jackman: "Re: Expect : Using a variable length list containing expect regexps?"
- Reply: Glenn Jackman: "Re: Expect : Using a variable length list containing expect regexps?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Apr 2004 12:10:46 -0700
I'd like to create a proc which takes a list containing regular
expressions and uses those as regexps in an expect block. The list can
be of arbitrary length. I'm not sure how to accomplish this. The main
problem I see is that you need to hard-code each regexp in the expect
block, but that means I cannot pass an arbitrary length list of
regexps.
Here's my hard-coded solution (but, using this approach, how can I
handle an arbitrary length of your_regexp_LIST?) :
proc expect_these {spawn_id your_regexp_LIST} {
expect {
-re [lindex $your_regexp_LIST 0] {
puts "GOT first regexp"
}
-re [lindex $your_regexp_LIST 1] {
puts "GOT second regexp"
}
}
}
..<spawn something>..
..<send something>..
expect_these $spawn_id [list \
"localhost" \
"127.0.0.1" \
]
- Next message: Craig: "Re: dqkit - link problem (almost there though)"
- Previous message: Joi Osoy: "Compiling Tile on Windows"
- Next in thread: Glenn Jackman: "Re: Expect : Using a variable length list containing expect regexps?"
- Reply: Glenn Jackman: "Re: Expect : Using a variable length list containing expect regexps?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|