Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Expect problems

by sunadmn (Curate)
on Dec 16, 2005 at 04:57 UTC ( [id://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
SUNADMN
USE PERL

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.

    -imran

      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
      SUNADMN
      USE PERL

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-24 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found