Using dsjob -run -param to pass parameters

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
fkana
Participant
Posts: 17
Joined: Tue Apr 20, 2004 2:01 am

Using dsjob -run -param to pass parameters

Post by fkana »

Hi,

I need to use the dsjob -run -param to pass parameters to a DataStage job but the parameter values need to be prompts. How do i do this from the unix command line.

Tx.

Faeez
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What do you mean by "the parameter values need to be prompts"? :?

You have to know what values to use from the command line, there's no 'prompting' there. And you only need to pass in values that need to be overridden, otherwise they will take their default values.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jewelhaque
Participant
Posts: 11
Joined: Thu Feb 22, 2007 7:53 am

Re: Using dsjob -run -param to pass parameters

Post by jewelhaque »

You need to create a menu program using Unix which will prompt you for the input, then you could use them as parameter value. You could find out examples how to write menu program using Unix in online search.
fkana wrote:Hi,

I need to use the dsjob -run -param to pass parameters to a DataStage job but the parameter values need to be prompts. How do i do this from the unix command line.

Tx.

Faeez
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Thats rubbish. DataStage designer and director have excellent parameter prompts. dsjob is meant to be used for automated execution and not interactive execution.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Are you sure there aren't merits to the idea of ad-hoc executions of a jobstream? I've been in environments where this has been done. In fact, the sample ksh script I've posted here verifies that all required parameters are passed when engaging the jobstream.
Last edited by kcbland on Mon Mar 19, 2007 8:43 am, edited 1 time in total.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Sorry guys for the harsh words, in a bad mood this morning. But my understanding of the question was of a gui prompt. If anything other than that then I must have missed it.
Even I have scripted solutions where the parameters are being passed during execution, but thats via another file and not a prompt.
Once again, my apologies.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
fkana
Participant
Posts: 17
Joined: Tue Apr 20, 2004 2:01 am

Post by fkana »

THis is what i need to do:

I need to select data between variable date ranges.

MY select statement looks like this:

select *
from table
where timestamp between #StartDate# and #EndDate#;

I have non-DataStage users that get a unix script that they execute. The script includes the dsjob -run -param. SO when they double click on the script they should have the ability to add the start and end dates manually which then get passed on to the rest of the job sequencers.

Keep in mind that these guys dont have access to DataStage. Only to the unix script.

Tx.

Faeez
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You're going to want to wrap the dsjob executable in a script that has the necessary prompts and formats the dsjob command accordingly. I suggest you allow the script to look for either a fully qualified command line with options set, else go into a "prompt" mode to get the desired values.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Here's an example script that checks for a set number of command line values prior to running dsjob. Consider doing something similar, or using the options capability in ksh.

viewtopic.php?t=85578
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Can't these guys edit a file and put the parameter values in the file?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

If you know shell scripting then write it yourself.

dsjob -lparams Project Job

Will get you a list of params.

dsjob -paraminfo DwNav ParameterizeDSNs pDSN2Change

Will get you parameter information like the prompt and default values for parameter pDSN2Change in job ParameterizeDSNs in project DwNav.

You can then validate the parameter name use the prompt and default to whatever the job had.
Mamu Kim
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

We do get the parameter values out of a file. We do validate the parameter name against

dsjob -lparams Project Job

We have a global list of parameter values which can be overridden by a job level parameter file.

We have another script which will build these parameter files from the defaults.

The same script will display the log of this job when it finishes.

Here is the code to trap a kill signal.

Code: Select all

let JobRunningSw=0
# -----------------------------------------------------------------
function ExitProcFunction 
{ 
# -----------------------------------------------------------------
# This function will stop the DataStage job running. 
# -----------------------------------------------------------------

# -----------------------------------------------------------------
# If the exit code is specified, exit with that code. 
# -----------------------------------------------------------------
    if (( $# > 0 )) 
    then 
        if (( ${JobRunningSw} ))
        then
            echo "$DSPath/dsjob -stop $ProjectName $JobName"
            $DSPath/dsjob -stop $ProjectName $JobName
        fi
        CatLogFunction
        exit $1
    else 
        exit 0 
    fi 
} 
# -----------------------------------------------------------------
# trap everything
# -----------------------------------------------------------------

trap 'ExitProcFunction 1' 1 
trap 'ExitProcFunction 2' 2 
trap 'ExitProcFunction 3' 3 
trap 'ExitProcFunction 4' 4 
trap 'ExitProcFunction 5' 5 
trap 'ExitProcFunction 6' 6 
trap 'ExitProcFunction 7' 7 
trap 'ExitProcFunction 8' 8 
trap 'ExitProcFunction 9' 9 
trap 'ExitProcFunction 10' 10 
trap 'ExitProcFunction 11' 11 
trap 'ExitProcFunction 12' 12 
trap 'ExitProcFunction 13' 13 
trap 'ExitProcFunction 14' 14 
trap 'ExitProcFunction 15' 15 
If you kill this script the job keeps running. This code will stop the job as well.

You are welcome Craig.

Our job in this forum is not to hand you solutions or code them for you but to point you in the right direction. These code snipets should help.
Mamu Kim
fkana
Participant
Posts: 17
Joined: Tue Apr 20, 2004 2:01 am

Post by fkana »

Tx guys.

Will try it out....

Ciao.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kduke wrote:You are welcome Craig.
Umm... thanks! :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply