Download Documentation
Transcript
3
RETRIEVE FILES FROM SAFERSLEEP USING PERL
80
if ($retcode < 1)
{ &Die ("ERROR SQL failed: code ’$retcode’ \n<$SQLstmt>" );
} else
{ $sqlErrors = $myODBC->Error();
if ( $sqlErrors !˜ /\[911\].+\[1\].+\[0\]/ )
{ &Print("SQL problem ’$retcode’ \n<$SQLstmt> ($sqlErrors)\n" ) ;
$EXITCODE |= 1; # signal warning
};
};
};
}
Subsidiary routines follow in the next sections. They are ‘pretty standard’.
The log file is identified by -iar- after the file name.
sub Die
{ my ($e);
($e)=@_;
$EXITCODE += 128;
# ’fatal’
&Print("\n $e \nExit code +128", 0);
exit $EXITCODE;
# caution. SEE: http://perldoc.perl.org/functions/exit.html
# die "\n Fatal";
}
sub Print
{ my ($p, $level); # level is debugging level.
# 0=none, 1=overview, 2=detail, 3=picky
($p, $level)=@_;
if ($DEBUG >= $level) # if level is 0, always print!
{ if ($LOGPRINT)
{ print LOGFILE $p;
return;
};
print $p; # console print
};
}
sub OpenLog
{ my ($islog, $EZDIR, $FILENAME);
($islog, $EZDIR, $FILENAME)=@_;
if (! $islog) { return; }; # if not logging.
my $TODAY = &GetLocalTime();
my $logfile= $EZDIR . "log/$FILENAME-iar-$TODAY.LOG";
open (LOGFILE,
">$logfile") or die "*CRASH* Could not open LOG $logfile :$!\n";
print "\n Writing to log file: $logfile"; # clumsy
}