Page 1 of 1
Using dsjob -run -param to pass parameters
Posted: Mon Mar 19, 2007 7:48 am
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
Posted: Mon Mar 19, 2007 7:51 am
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.
Re: Using dsjob -run -param to pass parameters
Posted: Mon Mar 19, 2007 7:59 am
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
Posted: Mon Mar 19, 2007 8:04 am
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.
Posted: Mon Mar 19, 2007 8:17 am
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.
Posted: Mon Mar 19, 2007 8:29 am
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.
Posted: Mon Mar 19, 2007 10:57 am
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
Posted: Mon Mar 19, 2007 11:19 am
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.
Posted: Mon Mar 19, 2007 11:21 am
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
Posted: Mon Mar 19, 2007 11:53 am
by DSguru2B
Can't these guys edit a file and put the parameter values in the file?
Posted: Mon Mar 19, 2007 8:24 pm
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.
Posted: Mon Mar 19, 2007 8:32 pm
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.
Posted: Tue Mar 20, 2007 1:14 am
by fkana
Tx guys.
Will try it out....
Ciao.
Posted: Tue Mar 20, 2007 6:32 am
by chulett
kduke wrote:You are welcome Craig.
Umm... thanks!