Page 1 of 2

Pass in parameter to ExecCommand stage

Posted: Wed Nov 09, 2011 1:36 am
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.

Posted: Wed Nov 09, 2011 2:33 am
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

Posted: Wed Nov 09, 2011 7:29 am
by chulett
Show us the syntax you are using in the stage, what you are putting in each of the two property boxes.

Posted: Wed Nov 09, 2011 2:49 pm
by ray.wurlod
Job parameter references are not supported in the Command field; they must be in the Parameters field.

Posted: Wed Nov 09, 2011 7:47 pm
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.

Posted: Wed Nov 09, 2011 7:57 pm
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.

Posted: Wed Nov 09, 2011 8:15 pm
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.

Posted: Wed Nov 09, 2011 11:15 pm
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?

Posted: Wed Nov 09, 2011 11:20 pm
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

Posted: Wed Nov 09, 2011 11:42 pm
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?

Posted: Wed Nov 09, 2011 11:48 pm
by chulett
Remove the dot and the space, it is an absolute pathname and should start with the slash.

Posted: Thu Nov 10, 2011 12:03 am
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

Posted: Thu Nov 10, 2011 12:29 am
by pandeesh
Can you try to remove the line PRINT and run with the remaining part?

Posted: Thu Nov 10, 2011 12:35 am
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

Posted: Thu Nov 10, 2011 12:52 am
by pandeesh
Please include one echo $1 before your echo "the version is $version" and post the result