May 24, 2005, 06:25 PM
yogiPassing error code generated in FOCUS to UNIX shell script
Hello,
How can I pass error code generated in FOCUS (&FOCERRNUM or &RETCODE ) error code as to UNIX Shellscript? Basically I want to trap FOCUS errors while executing focus programs from UNIX shellscript.
Here is code in my shellscript. I have created error condition in my FOCUS program so that it will throw error but I am not able to catch that error in shellscript?
Also how do we pass error code to Windows BatchFile?
Thanks
#-----------Shell Script----------------
cd /eda/ibi/focexecs/prodcomm
/eda/ibi/srv52/wfspv2100/bin/edastart -f carrpt >> $LOGFILE
echo $RETCODE
echo $FOCERRNUM
if $? -ne 0 ; then
echo "$0 failed executing edastart-carrpt" >> $LOGFILE
exit 8;
fi
if $? -eq 0 ; then
echo "$0 Successful executing edastart-carrpt" >> $LOGFILE
exit 8;
fi
May 24, 2005, 07:46 PM
jbmuirWe have a perl script that checks both the $? and scans the log file for FOCUS errors. This works for us. Welcome to purgatory. :-)
May 24, 2005, 08:14 PM
yogijbmuir
Thanks for the warm welcome!
Does your perl script returns you value in $?
Also when you are scanning log which I belive you mean is edaprint.log, How do you make sure that error is not from other program and everything is kosher?
THanks
May 25, 2005, 02:30 PM
jbmuirThe edaprint log is worthless, and edastart does not return a useful return code (as you've discovered). Here's a simple example that includes a test fex that has an error in it, and a perl script that runs edastart and captures the error.
TABLE FILE CAR
PRINT
COUNTRSYDSD
END
-RUN
#!/usr/bin/perl -w
use strict;
use English;
my $logfile = 'test.log';
my $rc = system(qq(/path/to/edastart -x "ex test" > $logfile));
my $focerr = scanlog($logfile);
print "rc: $rc focerr: $focerr\n";
sub scanlog
{
my $logfile = shift(@_);
my $focerr = 0;
open IN, "X$logfile" or die "Could not open $logfile: $ERRNO\n";
while (my $line = <IN>
{
chomp $line;
next if (!($line =~ m/\(foc(\d+)\)/io)); # Got a (FOCnnnn) error?
$focerr = $1;
last;
}
close IN;
return $focerr;
}
BTW, You'll have to change the 'X' in "X$logfile" to a "less than" character due to this persnickety bulletin board software. Grrrrrrr.
HTH, -James