Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Wait and retry loop without goto

by aaron_baugher (Curate)
on May 15, 2015 at 02:50 UTC ( [id://1126728]=note: print w/replies, xml ) Need Help??


in reply to Wait and retry loop without goto

A do-while loop should do the job without the goto:

my $output; my $tries = 0; do { $output = `expect -f show_running_config.exp $router->[$IP]`; if($?){ # subshell returns error $tries++; # count a try sleep 5; # pause } } while( $? and $tries < 4 ); # loop again if error and more tries # was the last try unsuccessful? if($?){ # last try was an error, ran out of tries print "Unable to connect after $tries tries\n"; exit; } # go on to handle the response in $output

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.

Replies are listed 'Best First'.
Re^2: Wait and retry loop without goto
by samuelk1 (Initiate) on May 15, 2015 at 03:13 UTC
    Thanks, I didn't think of that. Works great.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found