[TriLUG] perl question
Patrick Brewer
patwbrewer at yahoo.com
Sat Mar 14 12:16:32 EDT 2009
> I, um, "expect" that this is too late, but
>
> eval {
> $ssh = Expect->spawn("ssh -l $username $ip") || die "didn't work: $!\n";
> };
> next if $@;
>
> William Sutton
While not as elegant as the above, assuming the above works. I have used the following:
$worked=1;
<Do something> || $worked=0;
If (! $worked) {
<do something else>
}
die is great for hacked together scripts, but not for something that runs as part of a production service. In that case you want more robust or sophisticated error handling. Or perhaps to retry after a few seconds.
Patrick
More information about the TriLUG
mailing list