Re: What to "expect".... ?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: What to "expect".... ?

From: Khaled <nospam.ksubs@free.fr>
Date: Sun May 29 2005 - 18:02:20 CEST

Hello,

Let's have a look again at your code. Your [expect] statement boils
down to:

expect "pattern1" {action1} "pattern2" {action2} ... "patternx"
{actionx}

Here, [expect] will test incoming output against the patterns in the
statement in their specified order, i.e, it will attempt first to match
"pattern1" then "pattern2" and so on. As soon as a pattern is matched,
the corresponding action is performed and the [expect] statement
terminates, passing control to the next statement in the script.

If you want to look as well for the other patterns, write successive
expect statement for each pattern and the associated action, or use
[exp_continue] as shown in the example below:

expect {
   -i $spawnId
   "pattern1" {
      action1
      exp_continue
   }
   "pattern2" {
      action2
      exp_continue
   }
   "pattern3"
      action3
      # expect statement will end here after pattern3
      # is matched and action3 is performed
   }
}

Regrds,
Khaled

dushkin wrote:
> Hi guys!
> This is an "Expect" question (if there is a better group for it - let
> me know...
>
> While stdout has this prompt:
>
> *********************************************
> Connecting to 10.106.242.91...
> The authenticity of host '10.106.242.91 (10.106.242.91)' can't be
> established.
> RSA key fingerprint is e1:c1:00:ed:bd:62:82:24:d4:62:b3:df:f4:c3:e8:f4.
> Are you sure you want to continue connecting (yes/no)?
> *********************************************
>
> I evaluate the following "expect" command:
>
> *********************************************
> expect -i exp_spawn0 -gl "yes" {set var 2} -gl "10.106.242.91" {set var
> 1} ... (more patterns-actions come here...) -gl "some pattern"
> *********************************************
>
> I need to find the word "yes"! But I get the IP string al the time, and
> thus var is set to 1.
>
> What is wrong here???
> Thanks!!!
Received on Thu Sep 29 14:19:36 2005