detecting alternate cases in Expect 
Author Message
 detecting alternate cases in Expect

I want to be able to detect two alternate host responses in an Expect
script. But saying expect "foo" is always looking for a particular
string--I want to detect two alternate strings and act accordingly. How
do you usually handle this?


Tue, 04 Apr 2006 22:47:22 GMT  
 detecting alternate cases in Expect

Quote:

>  I want to be able to detect two alternate host responses in an Expect
>  script. But saying expect "foo" is always looking for a particular
>  string--I want to detect two alternate strings and act accordingly. How
>  do you usually handle this?

    expect {
        "answer 1" { action 1 }
        "answer 2" { action 2 }
        timeout    { got tired of waiting  }
        eof        { end-of-file (i.e. spawned process died) }
        default    { unexpected result }
    }

Similar examples appear in the expect man page.

--
Glenn Jackman
NCF Sysadmin



Tue, 04 Apr 2006 23:25:02 GMT  
 detecting alternate cases in Expect


Quote:

>>  I want to be able to detect two alternate host responses in an Expect
>>  script. But saying expect "foo" is always looking for a particular
>>  string--I want to detect two alternate strings and act accordingly. How
>>  do you usually handle this?

>    expect {
>        "answer 1" { action 1 }
>        "answer 2" { action 2 }
>        timeout    { got tired of waiting  }
>        eof        { end-of-file (i.e. spawned process died) }
>        default    { unexpected result }
>    }

>Similar examples appear in the expect man page.

                        .
                        .
                        .
... as well as the superbly valuable book, *Exploring
Expect* <URL: http://wiki.tcl.tk/ExploringExpect >.
--


Business:  http://www.Phaseit.net



Tue, 04 Apr 2006 23:52:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Alternate location for ruby-expect?

2. Detecting Multiple Events (was: Case Statements...)

3. Upper case / Lower case I'm a lost case

4. CASE vs case vs Case...

5. Expect: Detecting EOF in spawned TCL program

6. expect: detect a spawned process is still alive and not hung

7. detecting keypress while printing in expect?

8. Case sensitivity - serious question; no answer expected

9. Newbie Expect Question: where does Expect store values returned from an expect command

10. expecting 2different expects with expect

11. Convert All UPPER CASE to Upper and Lower case function

12. Add a case to a case structure programatically

 

 
Powered by phpBB® Forum Software