Expect: Trouble 'expect'ing linefeeds 
Author Message
 Expect: Trouble 'expect'ing linefeeds

[ warning:  a couple of scripts (not v. long) listed below]

Hi,

I'm trying to get an expect program talking to another expect program
that it has spawned.  However, I am running into some trouble which I
can't understand.

The original script is as follows:

set var_list {var1 var2 var3 var4}

set timeout -1

spawn expect2.exp

send "$var_list\n$argv\n"
log_user 0
expect "got it\n" { puts "Received" }
log_user 1
send_user "$expect_out(0,string)\n"

-------------------------------------

expect2 is as follows:

set timeout -1

### Read in variable list
expect_user -re "\[^\n]*\n"         ;#  Read in one line only
set var_list $expect_out(0,string)
set var_list [string trim $var_list "\n"]  ;# Strip the linefeeds

### Read in parameter list from spawning process
expect_user -re "\[^\n]*\n"
set args $expect_out(0,string)
set args [string trim $args "\n"]  ;# Strip the linefeeds

### Verify receipt
send_user "got it\n"

=======================================

When I run the script, the following occurs:

prompt> test2.exp par1 par2 par3 par4 par5 par6
spawn sequence.exp
can't read "expect_out(0,string)": no such element in array
    while executing
"send_user "$expect_out(0,string)..."
    (file "test2.exp" line 16)

The expect "got it\n" failed.

If I change the pattern to : expect "got it", then the script
works fine.  This may seem like a small error, but it is really
bugging me.  Anyone know why the linefeed is changing things?

Regards,
Sal.
--
                          | "So, so you think you can tell
   Salman Ali             |  heaven from hell, blue skies from pain"

                          |  



Mon, 22 Mar 1999 03:00:00 GMT  
 Expect: Trouble 'expect'ing linefeeds

: [ warning:  a couple of scripts (not v. long) listed below]

: Hi,

: I'm trying to get an expect program talking to another expect program
: that it has spawned.  However, I am running into some trouble which I
: can't understand.

: The original script is as follows:

: set var_list {var1 var2 var3 var4}

: set timeout -1

: spawn expect2.exp

: send "$var_list\n$argv\n"
: log_user 0
: expect "got it\n" { puts "Received" }
: log_user 1
: send_user "$expect_out(0,string)\n"

: -------------------------------------

: expect2 is as follows:

: set timeout -1

: ### Read in variable list
: expect_user -re "\[^\n]*\n"         ;#  Read in one line only
: set var_list $expect_out(0,string)
: set var_list [string trim $var_list "\n"]  ;# Strip the linefeeds

: ### Read in parameter list from spawning process
: expect_user -re "\[^\n]*\n"
: set args $expect_out(0,string)
: set args [string trim $args "\n"]  ;# Strip the linefeeds

: ### Verify receipt
: send_user "got it\n"

: =======================================

: When I run the script, the following occurs:

: prompt> test2.exp par1 par2 par3 par4 par5 par6
: spawn sequence.exp
: can't read "expect_out(0,string)": no such element in array
:     while executing
: "send_user "$expect_out(0,string)..."
:     (file "test2.exp" line 16)

Try the debug option -d to see what expect really get when you do
'expect "got it\n"'

Hope this help,
Simon

: The expect "got it\n" failed.

: If I change the pattern to : expect "got it", then the script
: works fine.  This may seem like a small error, but it is really
: bugging me.  Anyone know why the linefeed is changing things?

: Regards,
: Sal.
: --
:                           | "So, so you think you can tell
:    Salman Ali             |  heaven from hell, blue skies from pain"

:                           |  



Tue, 23 Mar 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. 'with'ing and 'use'ing

2. un-'upvar'ing/un-'global'ing variables

3. Expect'ing large amounts of output, versus performance measuring

4. Expect'ing Multixterm

5. expect'ing 8 char strings

6. Expect: Expect won't die after catching a signal when running w/o a tty

7. Need to temporarily step outside of expect's send/expect model

8. FTP'ing and FAX'ing from within C4b

9. trouble exec'ing tclsh and wish

10. '"""' and linefeed characters

11. re.LOCALE | re.IGNORECASE doesn't work as you'd expect

12. Expect and sending command 'resize'

 

 
Powered by phpBB® Forum Software