Running DS Job from Unix command line

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
laiko
Premium Member
Premium Member
Posts: 35
Joined: Sun May 25, 2008 10:55 am

Running DS Job from Unix command line

Post by laiko »

I have entered the following in unix command line:

Code: Select all

/DS/Ascential/DataStage/DSEngine/bin/dsjob -run -jobstatus -wait -mode NORMAL -param JOB_ID=98246 PREVRUNDT="2010-03-20 18:00:00" CURRRUNDT="2010-03-21 18:00:00" -warn 50 APPPRJ Load_Target
It errored out with the following message:

Code: Select all

Invalid arguments: dsjob -run
                        [-mode <NORMAL | RESET | VALIDATE>]
                        [-param <name>=<value>]
                        [-warn <n>]
                        [-rows <n>]
                        [-wait]
                        [-opmetadata <TRUE | FALSE>]
                        [-disableprjhandler]
                        [-disablejobhandler]
                        [-jobstatus]
                        [-userstatus]
                        [-local]
                        [-useid]
                        <project> <job|jobid>
What can be wrong here???
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Try putting -param in front of each parameter.

I can't access a system right now to test, but that may fix it.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What Andy means is

Code: Select all

/DS/Ascential/DataStage/DSEngine/bin/dsjob -run -jobstatus -wait -mode NORMAL -param JOB_ID=98246 PREVRUNDT="2010-03-20 18:00:00"-param CURRRUNDT="2010-03-21 18:00:00" -warn 50 APPPRJ Load_Target
Note the extra "-param" ahead of CURRRUNDT.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Code: Select all

/DS/Ascential/DataStage/DSEngine/bin/dsjob -run -jobstatus -wait -mode NORMAL -param JOB_ID=98246 -param PREVRUNDT="2010-03-20 18:00:00"-param CURRRUNDT="2010-03-21 18:00:00" -warn 50 APPPRJ Load_Target
Should be another one in front of PREVRUNDT as well...

Let us know if that fixes it.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
laiko
Premium Member
Premium Member
Posts: 35
Joined: Sun May 25, 2008 10:55 am

Post by laiko »

Yes, that worked by adding -param before each parameter. Thank you.

I am going to put this code in a shell script. I have something like

Code: Select all

DSPath="/DS/Ascential/DataStage/DSEngine/bin"

paramvals="param JOB_ID=98246 -param PREVRUNDT='2010-03-20 18:00:00' -param CURRRUNDT='2010-03-21 18:00:00'"

conn="$DSPath/dsjob"
paramlist=" -run -jobstatus -wait -mode NORMAL $paramvals -warn 50 "
jobinfo=" APPPRJ Load_Target"

$conn $paramlist $jobinfo
This does not work and says:

Code: Select all

Invalid arguments: dsjob -run
                        [-mode <NORMAL | RESET | VALIDATE>]
                        [-param <name>=<value>]
                        [-warn <n>]
                        [-rows <n>]
                        [-wait]
                        [-opmetadata <TRUE | FALSE>]
                        [-disableprjhandler]
                        [-disablejobhandler]
                        [-jobstatus]
                        [-userstatus]
                        [-local]
                        [-useid]
                        <project> <job|jobid>
But it works if I have:

Code: Select all

DSPath="/DS/Ascential/DataStage/DSEngine/bin"

conn="$DSPath/dsjob"
jobinfo=" APPPRJ Load_Target"

$conn -run -jobstatus -wait -mode NORMAL param JOB_ID=98246 -param PREVRUNDT='2010-03-20 18:00:00' -param CURRRUNDT='2010-03-21 18:00:00' -warn 50 $jobinfo
The list of parameters are dynamic so I'd like to put them in a string for readability of the code. I am really puzzled why it is not running when I am using variables.
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

It fails because UNIX treats the "special" characters like the $ sign differently because of the quotes around it. Try using echo on the variables to see what Unix is actually submitting and you will probably see some differences from what you expect in terms of the finished command.

You'll need to play around a bit to get the quotes correct if you use environment variables to store the various pieces.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

paramvals="-param JOB_ID=98246 -param PREVRUNDT='2010-03-20 18:00:00' -param CURRRUNDT='2010-03-21 18:00:00'" 
Add dash before first param
You are the creator of your destiny - Swami Vivekananda
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Good catch on the typo! I need to get my contacts prescription updated.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
laiko
Premium Member
Premium Member
Posts: 35
Joined: Sun May 25, 2008 10:55 am

Post by laiko »

My bad... that's really a typo when I posted the question. But in the actual case, it really has a dash. So this does not work either:

Code: Select all

DSPath="/DS/Ascential/DataStage/DSEngine/bin" 

paramvals="-param JOB_ID=98246 -param PREVRUNDT='2010-03-20 18:00:00' -param CURRRUNDT='2010-03-21 18:00:00'" 

conn="$DSPath/dsjob" 
paramlist=" -run -jobstatus -wait -mode NORMAL $paramvals -warn 50 " 
jobinfo=" APPPRJ Load_Target" 

$conn $paramlist $jobinfo
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Add set -vx and show the trace of your script
You are the creator of your destiny - Swami Vivekananda
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Try the following

Code: Select all

DSPath="/DS/Ascential/DataStage/DSEngine/bin" 

paramvals="-param JOB_ID=98246 -param 'PREVRUNDT=2010-03-20 18:00:00' -param 'CURRRUNDT=2010-03-21 18:00:00'" 

conn="$DSPath/dsjob" 
paramlist=" -run -jobstatus -wait -mode NORMAL $paramvals -warn 50 " 
jobinfo=" APPPRJ Load_Target" 

eval $conn $paramlist $jobinfo
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply