Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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]
[thezip]: Amazing speed and stealth in that one.
[GotToBTru]: You can't tunafish, but some seafood companies can tunafish. More fun with English.
[virtualsue]: a veterinarian told me to cut down on my cat's food. i said, when i do that she just catches more mice
[thezip]: My dogs are also excellent mousers, at least that's what they tell me.
[GotToBTru]: our beagle has dispatched 3 rabbits to the Great Hutch in the Sky since March.
[thezip]: I can always tell when the dogs have been mousing, as there is a concentric ring of mud around the end of their snouts when they do.
[thezip]: As for more physical evidence, that always seems to be missing somehow
[Rabbi Bob]: We have a Jack Russell: off the leash she is a torpedo against mice, rats, chipmunks and squirrels
[Rabbi Bob]: Doesn't eat them, just snaps, kills, drops and moves on.
[thezip]: Efficient, that one.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (15)
As of 2017-11-17 19:55 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (272 votes). Check out past polls.