DSExecute/ExecSH

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
Triton46
Charter Member
Charter Member
Posts: 83
Joined: Fri Feb 07, 2003 8:30 am

DSExecute/ExecSH

Post by Triton46 »

Is there a way to pass parameters from a batch job to a unix script without the use of a text file?

I have a batch file that invokes dsjob in a unix script and I would like to pass the parameters from that batch to the job being called by dsjob.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Unless I'm missing something, this should be simple. Can't you just use the parameter values in the batch to build the string that invokes the script? Just include the values after the path/name of the script, just like you were invoking it from the command line, and then refer to $1, $2, etc in the script.

Is that what you are looking for?

-craig
Triton46
Charter Member
Charter Member
Posts: 83
Joined: Fri Feb 07, 2003 8:30 am

Post by Triton46 »

That can be done in the unix script to pick up the values, but I am not sure how to pass them from the batch. There are two ways to invoke a unix script:

ExecSH = which only gives you a place to put the unix script name
DSExecute = I am having problems with the syntax. I wrote a DSExecute but it faults out every time.

quote:Call DSExecute("UV","/datastage/DataStage/Projects/DRDWSysRes/test_run.ksh", Output, ErrCode)
If ErrCode 0 Then
GoTo MissingFiles
End
MissingFiles:
Call DSLogWarn("WARNING WARNING DANGER DANGER", "DimCONTROL")
NormalExit:

How would I gather the parameters to be passed using the above statement? Also, why does it always error out?
Triton46
Charter Member
Charter Member
Posts: 83
Joined: Fri Feb 07, 2003 8:30 am

Post by Triton46 »

Answering my own questions again. :)

After reading some more, I took out the MissingFiles section and it worked perfectly.

quote:homeDir = pODSDSN
ErrCode = 0

Call DSExecute("UNIX","/datastage/DataStage/Projects/DRDWSysRes/test_run.ksh",homeDir,ErrCode)

Now, I have passed homeDir in, but what if I want several parameters passed in?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your code fell through to MissingFiles in all cases.
Call DSExecute("UV","/datastage/DataStage/Projects/DRDWSysRes/test_run.ksh", Output, ErrCode)
If ErrCode 0 Then
GoTo MissingFiles
End
GoTo NormalExit: ; *
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Just build up the command line as you would interactively. In the following code the := operator is "append to existing string". Look in the BASIC manual, which IS installed with your DataStage clients.
Note also that you were trying to execute a UNIX shell script in the UV shell - I doubt that this would work.

Shell = "UNIX"
Command = "/datastage/DataStage/Projects/DRDWSysRes/test_run.ksh"
Command := " " : Parameter1
Command := " " : Parameter2
* ... and so on
Output = ""
ErrCode = 0

Call DSExecute(Shell, Command, Output, ErrCode)
If ErrCode 0 Then
GoTo MissingFiles
End
GoTo NormalExit
MissingFiles:
Call DSLogWarn("WARNING WARNING DANGER DANGER", "DimCONTROL")
NormalExit:


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Did that work for you, Triton46? It's important to realize the DSExecute 'command' is not just for the *name* of the script. It allows a *complete* command line to be passed - arguments and all - which can then be processed by the script. Actually, this is true of both DSExecute and ExecSH.

-craig
Post Reply