On Tue, Sep 24, 2002 at 10:18:58AM -0400, chad kellerman wrote: > Is there a way I can "mark" a part of a script so that, if I wrap an > eval around a particular statement I can go back to that mark and retry > it. > > I have to make quite a few ssh connections to various servers, I was > wondering if I could put a mark before the ssh and if it dies have it go > back to a point before the connection and retry in a a few seconds.
Why not simply loop until you succeed? while (1) { eval { ... ssh code ... }; if ($@) { sleep(10); } else { last; } } You could even wrap this up in a convenient subroutine. sub try_ssh { my($sub) = @_; while (1) { eval { &$sub }; if ($@) { sleep(10); } else { last; } } } Then call try_ssh() thusly: try_ssh(sub { ... ssh code ... }); > I would rather not create a whole sub routine. Because I would have to > create about 10 of them for evey different ssh connection since there is > something different done on each connection. Do you wrap eval around just the part where you connect to the remote end, or do you wrap the eval around all of the code, including the connection and the conversation (commands, etc.)? Are you certain you want to retry the entire thing if the conversation fails? You could very well be retrying forever if there's something wrong in the conversation that will not fix itself by simply retrying. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]