Re: [expect] using the previous output as input

From: Sektor van Skijlen (ethouris_at_wp.spamu.lubie.nie.pl)
Date: 08/12/04


Date: Thu, 12 Aug 2004 18:25:50 +0000 (UTC)

Dnia Thu, 12 Aug 2004 17:58:11 +0000 (UTC), kostas@hotmail.nospam skrobie:
> Hello!

> How can i use the output of the remote program as the input
> of an expect send clause?

> For example, the remote program responds with:

> My name is lampros

> (while "lampros" is a totally random name)

> I want to send back to the remote program something like:

> Hello, lampros and have a nice day.

expect -re "My name is (.*)$"
set name $expect_out(1,string)
send "Hello, $name and have a nice day."

Of course you have to verify this regular expression whether it matches your
needs.

Use -d option with expect command and you'll see, which global variables
expect sets during "expecting".

-- 
//  _    ___         Michal "Sektor" Malecki <sektor(whirl)kis.p.lodz.pl>
\\ L_ |/ `|  /^\ ,()                         <ethourhs(O)wp.pl>
// \_ |\  \/ \_/ /\ C++ bez cholesterolu: http://www.intercon.pl/~sektor/cbx


Relevant Pages