Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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


Comment on Re: Expect problems
Select or Download Code
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
Node Status?
node history
Node Type: note [id://517138]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-07-28 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (189 votes), past polls