How to pass variable $APT_CONFIG_FILE from 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
singhald
Participant
Posts: 180
Joined: Tue Aug 23, 2005 2:50 am
Location: Bangalore
Contact:

How to pass variable $APT_CONFIG_FILE from script

Post by singhald »

Hi all

I am using shell script S1 to call the datastage sequence. I am writing all job parameters in a parameter file and script is using this parameter file.

In my main script i am calling a small shell scripts to launch the datastage sequence and providing input that parameter file.
in small script i am using the below command to run ds sequence

JobStatus=`dsjob -run -warn 9999 $ParmList -jobstatus $ProjName $JobName`

$ParmList ----> this input parameter file (contians all job parameter mentioaned in the sequence like, dbserver,dbuser,dbpwd,inputDir,OutputDir etc.).

Now i want to add $APT_CONFIG_FILE in sequence job parameters.
and want to pass the value from the parameter file.

i think beacause of $sign, i am not able to pass the config file.

Please let me know if some have already faced this issue.

Regards,
Regards,
Deepak Singhal
Everything is okay in the end. If it's not okay, then it's not the end.
OddJob
Participant
Posts: 163
Joined: Tue Feb 28, 2006 5:00 am
Location: Sheffield, UK

Post by OddJob »

Try enclosing $APT_CONFIG_FILE in single quotes to stop the $ being expanded.

You could enclose in single quotes all of your param names so you wouldn't have to make a distinction between env vars and other params.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can also "escape" the dollar sign. \$APT_CONFIG_FILE

This and "hard quotes" are standard shell scripting techniques. Perhaps some learning is required.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

add this parameter -param '$APT_CONFIG_FILE=<configuration file name with path>'
singhald
Participant
Posts: 180
Joined: Tue Aug 23, 2005 2:50 am
Location: Bangalore
Contact:

Post by singhald »

hi

in my parameter file i am writing the parameter name it self like,

$APT_CONFIG_FILE=/opt/Ascential/DataStage/Configurations/2Node.apt
InputDir=/home/source/
InputFileName=emp.dat
OutputDir=/home/target/
OutputFileName=emp.out
RejectDir=/home/reject/
RejectFileName=emp.rej

then i am passing it to script.

but it is not taking the configuration file because of $ sign, i have tried some escape sequece,but not able to resolve this issue.
Regards,
Deepak Singhal
Everything is okay in the end. If it's not okay, then it's not the end.
pchapma5
Participant
Posts: 6
Joined: Mon Oct 08, 2007 6:56 am

Post by pchapma5 »

In your parameter file you need something like this for all your parameters :

t_config_file=/opt/Ascential/DataStage/Configurations/2Node.apt

Then in your script, you need something like this :

-param '$APT_CONFIG_FILE'=$t_config_file

Hope this helps
singhald
Participant
Posts: 180
Joined: Tue Aug 23, 2005 2:50 am
Location: Bangalore
Contact:

Post by singhald »

Thanks for your help.

I cann't change this command written in the script,

i need to provide the list if parameter to the below script as $ParmList.

JobStatus=`dsjob -run -warn 9999 $ParmList -jobstatus $ProjName $JobName

if i follow the coding logic given by you , i need to write the all parameter name followed by the paramter file name

Regards,
Regards,
Deepak Singhal
Everything is okay in the end. If it's not okay, then it's not the end.
pchapma5
Participant
Posts: 6
Joined: Mon Oct 08, 2007 6:56 am

Post by pchapma5 »

Looking at your original list of parameters, I think they should look like this :
'$APT_CONFIG_FILE'=/opt/Ascential/DataStage/Configurations/2Node.apt
'InputDir'=/home/source/
'InputFileName'=emp.dat
'OutputDir'=/home/target/
'OutputFileName'=emp.out
'RejectDir'=/home/reject/
'RejectFileName'=emp.rej

This is assuming the literals to the left of each equality is the parameter name of the job/sequence you are running ?
Hope this helps.
singhald
Participant
Posts: 180
Joined: Tue Aug 23, 2005 2:50 am
Location: Bangalore
Contact:

Post by singhald »

thanks for ur reply,

I have used this options as welll, but it is not working for me,
Regards,
Deepak Singhal
Everything is okay in the end. If it's not okay, then it's not the end.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: How to pass variable $APT_CONFIG_FILE from script

Post by chulett »

singhald wrote:i think beacause of $sign, i am not able to pass the config file.
No, it's because each parameter name/value pair must be prefixed by "-param", each and every one. You need iterate thru the file and concatenate a string together so that you end up with:

Code: Select all

-param InputDir=/home/source/ -param OutputDir=/home/target/
Etc. And note that you cannot quote the parameter names in your file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
prabhakar_raok
Participant
Posts: 4
Joined: Fri Aug 01, 2008 12:54 pm

Passing $APT_CONFIG_FILE for invoking a Datastage Sequence

Post by prabhakar_raok »

I have the same issue as above and which I wanted to check if anyone has implemented it earlier for a Datastage Sequence; I know this works when invoking a Datastage job but wanted to know if it works for a Sequence;

Here's what I wanted to do.

1) The Datastage Stage "Sequence" is being invoked from Command script; and this sequence inturn is invoking multiple Datastage Jobs; The reason to call the jobs thorugh the sequence is to simplify the calling procedure of the jobs by minimising the passing of the parameters which could be easliy set up in the Sequence.

2) However there is one parameter I still want to control at the Sequence level; i.e that is APT_CONFIG_FILE, setting up different config files for different sequences depending on the volume of data I need to churn for each sequence flow.

Here's how I tried to implement it;

I used to echo command to see the output of the command I am using and also used the actaul command call in the next line and here's the error I am getting; Can anyone of you help in how to resolve this issue;


------------------

# Run Job Sequence script; this is being called from a wrapper script

echo dsjob -run -wait -warn 1000000 -jobstatus -param "\$APT_CONFIG_FILE=$APT_CONFIG_FILE" $PROJECT $SEQUENCE

dsjob -run -wait -warn 1000000 -jobstatus -param "\$APT_CONFIG_FILE=$APT_CONFIG_FILE" $PROJECT $SEQUENCE



---------------------

the output of the above command

dsjob -run -wait -warn 1000000 -jobstatus -param $APT_CONFIG_FILE=/home/app/is/opt/IBM/InformationServer/Server/Configurations/config2node.apt Project_name Sequence_1

Error -3 getting information for parameter '$APT_CONFIG_FILE'

Status code = -3 DSJE_BADPARAM

-----------------------


Your help is greatly appreciated.
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Your answer is all the way back up in the second post of this thread from OddJob. You need to protect your parameter names from the shell.

Mike
prabhakar_raok
Participant
Posts: 4
Joined: Fri Aug 01, 2008 12:54 pm

Post by prabhakar_raok »

Hi Mike,

I am not sure if I understood you; infact I am protecting the env variable by having a backslash in the referecne to the $APT_CONFIG_FILE; however I have also tried the option which you had suggested; here is the modifed code and the results for the same

--- Code; the first call is just an echo where in the second call, I am calling the script by protecting the $APT_CONFIG_FILE using a single quote and also tried by using a \ in my previous call; I had also hardcoded the APT_CONFIG_FILE path to test this

# Run Job Sequence

echo dsjob -run -wait -warn 1000000 -jobstatus -param '$APT_CONFIG_FILE=/home/app/is/opt/IBM/InformationServer/Server/Configurations/config2node.apt' $PROJECT $SEQUENCE

dsjob -run -wait -warn 1000000 -jobstatus -param '$APT_CONFIG_FILE=/home/app/is/opt/IBM/InformationServer/Server/Configurations/config2node.apt' $PROJECT $SEQUENCE

-------the first output is an echo command and the second is the actual call in the results down blow (without the echo which is producing the error)

dsjob -run -wait -warn 1000000 -jobstatus -param $APT_CONFIG_FILE=/home/app/is/opt/IBM/InformationServer/Server/Configurations/config2node.apt DS_EDW js_omni_af_src_load


Error -3 getting information for parameter '$APT_CONFIG_FILE'

Status code = -3 DSJE_BADPARAM

So in your opinion; when this param is being passed to dsjob do you mean to say it is trying to expand it; sorry wasn't able to grasp your answer; so could you expand it.

Thanks for your answer though;
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

You need this:

Code: Select all

dsjob -run -wait -warn 1000000 -jobstatus -param '$APT_CONFIG_FILE'=/home/app/is/opt/IBM/InformationServer/Server/Configurations/config2node.apt Project_name Sequence_1
Mike
Post Reply