Hi. I have a simple source>join>target parallel job and when I run it on the Datastage it works fine, but when I run it using shell script it is returning errors. I'm currently on a much complex requirement where I should run 2 sequences using a shell script and trying my code on a smaller job before implementing. Can you point out if there are errors in the code.
# Initialize enviromental parameters to use Datastage commands.
cd /opk/IBM/InformationServer/Server/DSEngine
. ./dsenv > /dev/null 2>&1
#"Project Name"
Vambiente=DESA_HUB_NAL
# Name of the jobs that will be executed
VstrJob1=Using_Join
#Identify the status of the Datastage Job.
VmsgJobstatus=`dsjob -jobinfo $Vambiente $VstrJob1 | grep "Job Status" | cut -c14-20`
#Check status, if the last State was failed or stopped then reset the Job
if [ "$VmsgJobstatus" = "RUN FAI" ] || [ "$VmsgJobstatus" = "STOPPED" ]; then
echo " ... Resetting JOB: "$VstrJob1
dsjob -run -mode RESET $Vambiente $VstrJob1
fi
# Estimated date with hours and seconds to display the start time of execution
VfechaIni=`date +"%d%m%Y-%H:%M:%S"`
# Executes the job
dsjob -run -jobstatus $Vambiente $VstrJob1
if [ "$OUT" = "1" ]; then
Vmens=" The process ended successfully. "
echo $Vmens
Vest="OK"
VfechaFin=`date +"%d%m%Y-%H:%M:%S"`
OUT=0
elif [ "$OUT" = "2" ]; then
Vmens=" The process ended successfully, but there are warning for reviewing. "
echo $Vmens
Vest="WARNINGS"
VfechaFin=`date +"%d%m%Y-%H:%M:%S"`
OUT=0
else
Vmens=" The process ended with errors."
echo $Vmens
Vest="FAILED"
VfechaFin=`date +"%d%m%Y-%H:%M:%S"`
fi
The script returns the following after execution
Status Code = 0
Waiting for job....
Finished waiting for job
Job status : (1)
Look up what the jobstatus option does for the return codes. 1 = Ran OK, for example... which you seem to be expecting. Looks like an issue with $OUT as I don't see you setting that anywhere, only testing for it.
-craig
"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod wrote:Your script sets the variable OUT
Where? I see the first mention of it in the test for success and it's not set until after the first test for it. And since it is not set, it never passes the "=1" or "=2" test so the "OUT=0" bits never run.
Seems to me that's what is going on, anywho.
-craig
"You can never have too many knives" -- Logan Nine Fingers
I think that the = 1 or = 2 tests may have succeeded, but the value returned by them was never transferred to the exit status of the enclosing script itself, hence the advice I tendered.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi. I tried setting OUT = $? , removing the double quotes on the $OUT in the if statements and running again but now I'm getting this output:
Status Code = 0
Waiting for job...
Finished Waiting for job
Job Status : (1)
Status Code = 1
aa.sh [36]: OUT: not found
aa.sh [38]: test: 0403-004 Specify a parameter with this command.
aa.sh [46]: test: 0403-004 Specify a parameter with this command.
The process ended with errors.
I've read a previous post in here that status code 1 means that the job is running. But I want the script to echo that the job has been executed successfully. Any advice with be appreciated.