Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Expect problems

by sunadmn (Curate)
on Dec 16, 2005 at 04:57 UTC ( #517138=note: print w/replies, xml ) Need Help??

in reply to Expect problems

Ok so I did some further debuging and I have things working till the next case match:

[qr">> Real server $number - $", sub{ $spawn_ok = 1; my $fh = shift; print $fh "$apply\r"; sleep 2; exp_continue; }],
When I see the next >> Real server I am stuck in the apply loop and it wont send the save command, so I wondered if I could do a double match like look for the line before and then match the >> Real server line for the save command
[qr">> Real server $number - $", sub{ $spawn_ok = 1; my $fh = shift; print $fh "$save\r";
Does anyone have any thoughts on this??

Thanks all

Replies are listed 'Best First'.
Re^2: Expect problems
by CountOrlok (Friar) on Dec 16, 2005 at 15:48 UTC
    In the original code you were looking for the same pattern twice. You were probably thinking that the first time expect sees the prompt it would match the first case and that second time expect sees the prompt it would match the second case.

    This would not work. You need to, within one case, check to see how many times you have seen that prompt. Zero times? do your Apply. Seen it once before? do your save. Seen it twice before? do whatever you need to do next.

    In other words keep a counter of how many times you have come across that prompt and send the appropriate response.


      This probably going to sounds like a stupid question, but would you have a suggestion on how to keep the counter for the case matches??

      Thanks a million
      USE PERL

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://517138]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2021-03-08 03:50 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (123 votes). Check out past polls.