Pass in parameter to ExecCommand stage

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

Moderators: chulett, rschirm, roy

agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Pass in parameter to ExecCommand stage

Post by agathaeleanor »

Hi All,

I am trying to pass in a parameter to execute command stage, and based on the passed-in value, the shell script could execute accordingly.

However, the pass-in value is not able to pass down to the shell script. As i performed echo from the shell script, the log shown that the value being passed in is null.

Need your help on how the shell script would 'catch' the parameter value.
In shell script, i perform a variable assignment
version = "$1" so that the pass-in value assign to "version".

Pardon me if this has been answered, could you hint on the search keywords or the url. Many thanks.
kirankumarreddydesireddy
Participant
Posts: 110
Joined: Mon Jan 11, 2010 4:22 am

Post by kirankumarreddydesireddy »

We can pass parameters to run shell script in the ExecCommand stage same as that of shell script in Unix.

Example : you can type in the ExecCommand stage as below and it should work.

ksh test.sh #parameter1# #parameter2# #parameter3#




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

Post by chulett »

Show us the syntax you are using in the stage, what you are putting in each of the two property boxes.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Job parameter references are not supported in the Command field; they must be in the Parameters field.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Post by agathaeleanor »

Thanks all for your response.

I tried execute the shell script(without being called by datastage) it works.

Code: Select all

./RemoveTrailer_FI_MOH_Budget.sh #VER_ID#
In the property of execute command stage,

command:
. /u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh

Parameters:
#VER_ID#

Log says,

JobControl (@Execute_Command): Executed: . /u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh I
Reply=0
Output from command ====>
version is

Note that script is echo the version being passed in, but it is null.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

But it did it successfully (status = 0), which means that nothing was passed in.

Is VER_ID a parameter of the sequence? Please be aware that parameter names are case sensitive.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Post by agathaeleanor »

VER_ID is select from the list of parameter.

I am wondering why VER_ID is not being passed down to shell script.

Any workaround? Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm curious why you have a "dot space" at the beginning of the command? Does the behaviour change if you remove that?
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

So, Your script is like:

Code: Select all

version=$1
echo "version is $version"
In exec command activity stage :

command:Script name
parameter:#VER_ID#

What value you are actually passing to VER_ID in job sequence?
Make sure you are properly echoing inside the script.

Else, try to simulate the same in a jobcontrol code.
Try to PRINT the output of the command.
If that also not works, then you should report to your official support provider.

Thanks
pandeeswaran
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Post by agathaeleanor »

I'm curious why you have a "dot space" at the beginning of the command? Does the behaviour change if you remove that?
At first it looks weird to me as well, but when it get removed, the log says,

JobControl (@Execute_Command): Executed: ./u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh M
Reply=1
Output from command ====>
SH: ./u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh: not found
What value you are actually passing to VER_ID in job sequence?
Make sure you are properly echoing inside the script.
I am passing a character "M" into the script.
Part of the shell script looks like this,

Code: Select all

print "$1"
VERSION="$1"
echo "version is $VERSION"

if [ "$VERSION" = "M" ]; then
VNAME=`ls -1 -F|grep "FIN_MOH_BUDGET_INITIAL_.*.csv"|grep -v [/$]`
In the datastage log, it shows

JobControl (@Execute_Command): Executed: . /u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh M
Reply=0
Output from command ====>
SH: print: not found
version is


Actually i just found that after "version is" there is a linefeed. I am suspecting this is the culprit. How do trim the linefeed?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Remove the dot and the space, it is an absolute pathname and should start with the slash.
-craig

"You can never have too many knives" -- Logan Nine Fingers
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Post by agathaeleanor »

Hi Craig,
After removing the dot and the space, it hits error as below.

JobControl (@Execute_Command): Executed: /u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh "I"
Reply=1
Output from command ====>
SH: /u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh: not found
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Can you try to remove the line PRINT and run with the remaining part?
pandeeswaran
agathaeleanor
Participant
Posts: 76
Joined: Mon Mar 05, 2007 9:26 pm
Location: Malaysia

Post by agathaeleanor »

after removing print, job logged


JobControl (@Execute_Command): Executed: . /u01/dstage/hpbdev/Sequential/FI/Scripts/RemoveTrailer_FI_MOH_Budget.sh "M"
Reply=0
Output from command ====>
version is
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Please include one echo $1 before your echo "the version is $version" and post the result
pandeeswaran
Post Reply