package TestEngine::Testcase::Logic::Cmd;
use Test::More;
use base qw(Test::Cmd);
sub new
{
my ($self,$cmd) = @_;
my $self = {
cmd => $cmd,
type => "",
workdir => '/tmp/',
};
bless $self;
return $self;
}
sub isSuccess
{
my ($self) = @_;
my ($interpreter, $args);
if ($^O == 'linux') {
$interpreter = '/usr/bin/ksh';
$args = qq(-c "$self->{cmd}");
} elsif ($^O == 'MSWin32') {
# TODO: KNOWN ISSUE
# This interpret does not provide correct execute status
$interpreter = 'c:\windows\system32\command.com';
$args = "/c $self->{cmd}";
} else {
die "unsupported platform '$^O'";
}
# // todo: ensure run() return 0 for success, otherThan0 for failu
+re
#print qq($self->run(prog =>$interpreter, args =>$args ));
return ok($self->run(prog =>$interpreter, args =>$args ) == 0, $se
+lf->{desc} );
#print "$self->{desc}\n";
}
sub setDescription {
my ($self, $string) = @_;
$self->{desc} = $string;
}
1;
I am using above perl script package for checking the exit value from shell script which I had mentioned bellow. If shell script exit with “0 exit status” perl script will check in its “isSuccess” subroutine and pass OK. When I am checking exit status of shell script its giving 0 exit status. But in perl script it’s giving me NOT OK value. I am not able to figure it out where exactly the problem.
tag=0
for file in $Rejected_File_Path/*
#for file in /home/oracle/sarfaraz/scotia/QA_RELEASE_20120123/release/
+log/Rejected/*
do
# echo "$file"
file_name=`grep "#RD#" $file|cut -d"," -f8`
#echo "=====>>>$file_name"
#READING DATA FROM SQL OUTPUT FILE#
while read line
do
file_name_match=`grep "$file_name" $line`
#echo "------->>>$file_name_match----"
if [ "$file_name_match" == "$file_name" ]
then
rej_code=`grep ",2001," $file`
#echo "===$rej_code"
if [ "$rej_code" != "" ]
then
echo "FOUND REJECTION CODE"
tag=127
fi
else
echo "THRER IS NO ERROR CODE IN REJECTION FILE ...."
fi
done < tempimp1
done
#echo "==$tag"
rm -f tempimp1
#vel=`$?`
echo "===$val"
if [ "$tag" == "127" ]
then
echo "FINAL SUCCESS ...."
# echo "===$val"
echo $?
exit $val
else
echo "FAILED ...."
exit 127
fi
Thanks for your kind support
little update to narrow down my shell script problem when i run this program from perl script
1.when i am giving all mandatory paths on shell script itself (hardcoding the path) its exit with value 0 (zero)
2.when the same script use to read all mandatory path from external file then its exit with value "32512"
Is this problem to read external file which affect the exit status or another issue.
please suggest any approach