saibsk
asked on
invoke shell script from Perl
I am trying to execute a shell script which is giving me the following error.
system ksh check_xmlExtracts.ksh client638 source cl638 failed: 256 at run_dcm_scripts.pl line 12, <FH> line 1.
Perl script:
@args=("ksh", "check_Extracts.ksh","$arr ay[0]","$a rray[4]", "$array[2]");
system(@args)==0
or die "system @args failed: $?";
where @array=(client638 qsapp01 cl638 ATG source)
Please advise.
system ksh check_xmlExtracts.ksh client638 source cl638 failed: 256 at run_dcm_scripts.pl line 12, <FH> line 1.
Perl script:
@args=("ksh", "check_Extracts.ksh","$arr
system(@args)==0
or die "system @args failed: $?";
where @array=(client638 qsapp01 cl638 ATG source)
Please advise.
ASKER
instanceName=$1
source=$2
clientInstance=$3
portNum=4${instanceName##[ a-z]*[a-z] }
results=`isql -Sservername -Uuser -Ppassword <<EOF
set nocount on
go
select ipaddress from client_info where instancename = "$instanceName"
go
EOF`
ip=`echo "$results" | tail +3`
echo "IP:$ip\n";
echo "$portNum\n";
ssh $ip "grep ":$portNum" *> "$clientInstance$source"_x ml_extract .out
THis is the check_Extracts script. WHen I invoke this script with the directly supplying the inputs it works fine but when I invoke the shell script thru Perl with the input @array=(client638 qsapp01 cl638 ATG source) it throws the above error
source=$2
clientInstance=$3
portNum=4${instanceName##[
results=`isql -Sservername -Uuser -Ppassword <<EOF
set nocount on
go
select ipaddress from client_info where instancename = "$instanceName"
go
EOF`
ip=`echo "$results" | tail +3`
echo "IP:$ip\n";
echo "$portNum\n";
ssh $ip "grep ":$portNum" *> "$clientInstance$source"_x
THis is the check_Extracts script. WHen I invoke this script with the directly supplying the inputs it works fine but when I invoke the shell script thru Perl with the input @array=(client638 qsapp01 cl638 ATG source) it throws the above error
What is the status in $? when you invoke this script with the directly supplying the inputs ?
Does anything print when you invoke it from Perl?
is "$clientInstance$source"_x ml_extract .out creates when you invoke it from perl?
Does anything print when you invoke it from Perl?
is "$clientInstance$source"_x
ASKER
The $? is 256 when I invoke from Perl.
But when I execute directly the $clientInstance$source"_xm l_extract. out is created with the data.
But when I try from Perl even the file is not created.
How do I check $? when I direclty execute the shell script.
But when I execute directly the $clientInstance$source"_xm
But when I try from Perl even the file is not created.
How do I check $? when I direclty execute the shell script.
ASKER
when I printed the $? in my shell script it is printing 1. That means is my script failiing but t does generate the file with data. Please advise.
If the script does what you want despite returning a non-zero status, then perhaps you want to ignore the status.
Unless the status signifies something you don't wantin which case you may want to adjust the ksh script
It looks like the last command was a grep, which would return status 1 if the line is not found
Is that a problem?
Unless the status signifies something you don't wantin which case you may want to adjust the ksh script
It looks like the last command was a grep, which would return status 1 if the line is not found
Is that a problem?
ASKER
It is actually create the file even though the perl script dies when I invoke the shell script thru Perl. I don't understand what is wrong.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
when would it return a non zero status?