I want to do this in a shell script:
#!/usr/bin/ksh
PERL_PATH=/usr/local/bin/perl
RET1=$(${PERL_PATH} missing_months_wrap.pl)
echo $RET1
How do i do it?
calling the perl script as above is giving me an error:
> shell.sh
Can't return outside a subroutine at missing_months_wrap.pl line 269.
EDIT: inside the perl script the statements are :
unless (@pm1_CS_missing_months)
{
$SETFLAG=1;
}
my @tmp_field_validation = `sqlplus -s $connstr \@DLfields_validation.sql`;
unless (@tmp_field_validation)
{
$SETFLAG=1;
}
if ($SETFLAG==1)
{
return $SETFLAG;
}
The assignment to
RET1in your shell script runs the Perl command and captures its standard output. To make your Perl program go along, change the conditional at the end toRunning it produces
Another way is to use the exit status of the Perl program. With
shell.shcontainingand changing the last conditional in
missing_months_wrap.pltoyou get the same output: