shell script

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
studyguy2001
Participant
Posts: 19
Joined: Tue Feb 01, 2005 11:46 pm

shell script

Post by studyguy2001 »

hello.,

i am working on parallel extender v7.5.
i never write a shell script to run the datastage jobs.
i normally used datastage director to run the jobs.

i am new to shell scripting. can anyone please help me
with a sample shell script to run the datastage job.
in the shell script i also have to get the job status and
check whether the job is success or failure.

can anyone please help me.,

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

Post by chulett »

There's one here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
studyguy2001
Participant
Posts: 19
Joined: Tue Feb 01, 2005 11:46 pm

shell script

Post by studyguy2001 »

chulett wrote:There's one here.
Hello craig.,

if you have a sample shell script then can you please please provide me.
it will be a great help to me.

thanks
kevin
studyguy2001
Participant
Posts: 19
Joined: Tue Feb 01, 2005 11:46 pm

Re: shell script

Post by studyguy2001 »

hello.,

i am working on parallel extender v7.5.
i never write a shell script to run the datastage jobs.
i normally used datastage director to run the jobs.

i am new to shell scripting. can anyone please help me
with a sample shell script to run the datastage job.
in the shell script i also have to get the job status and
check whether the job is success or failure.

can anyone please help me.,

thanks
kevin
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The script to which Craig provided a link will run parallel or server jobs. No change is required, unless you want to control the value of the APT_CONFIG_FILE environment variable within the shell script. The dsjob command line interface is uninterested in the job type; it can start server jobs, parallel jobs or job sequences.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I was going to say - that is the sample. You did click on the link, did you not?
-craig

"You can never have too many knives" -- Logan Nine Fingers
nandu_infy
Participant
Posts: 3
Joined: Tue Feb 15, 2005 7:19 am

Shell Script

Post by nandu_infy »

Hi,

Here's some sample code...

If you want to run a dsjob from shell script...

${DSHOME}/bin/dsjob -run -param '$APT_CONFIG_FILE='$APT_CONFIG_FILE -param "STAGE_DIR=$STAGE_DIR" -param "INPUT_DIR=$INPUT_DIR" -warn "${warn_cnt}" -jobstatus ${DS_PROJ} Jobname

#to find out the status returned...
jobStatus=$?

Please not that whtvr you have $_______ or ${_______} are variables defined. You can define it in the shell script above before running the job.

eg:
export APT_CONFIG_FILE='/ascential/apt/Ascential/DataStage/Configurations/cfg4x4.apt'
export APT_BUFFER_MAXIMUM_TIMEOUT=1
export warn_cnt="nolimits"
export DS_PROJ="DEV_PROJ" (your ds project name)
export STAGE_DIR=${PROJ_DIR}/Data/staged etc...

Finding job status...

If you immediately follow jobStatus=$?
statement to the one running the job the status 1,2,3 or anything will be returned.

1- sucess without warnings
2- with warnings
3-aborted etc...

You might want to act further depending on the status, say reset the job if it aborts etc... The following function will take care of it...

Call the function ---check_status "Jobname" "$jobStatus"


check_status()
{
jobName=$1
jobStatus=$2

echo ""
if [[ $jobStatus -eq 1 ]] || [[ $jobStatus -eq 2 ]] || [[ $jobStatus -eq 141 ]]
then
echo "Job $jobName is successful with exit code $jobStatus"
else
echo "Job $jobName failed with exit code $jobStatus, script will reset the job and exit"
echo "Resetting the job..."
${DSHOME}/bin/dsjob -run -mode RESET ${DS_PROJ} ${jobName}
exit
fi
}
studyguy2001
Participant
Posts: 19
Joined: Tue Feb 01, 2005 11:46 pm

Re: Shell Script

Post by studyguy2001 »

Hello Everyone.,

Craig i went to the link and i saw the script.
i am now able t run my DS job using shell script you provided.

thanks a lot guys
bye
kevin
Post Reply