Page 1 of 1

Dynamically Setting Environment variables

Posted: Fri Jan 18, 2008 2:58 am
by Ush
Hi,

I have script which should set path(environment) variable dynamically.
If prj=dev then
$path=...
else
$path=....

Please let me know how to go about this.Thanks.

Posted: Fri Jan 18, 2008 5:52 am
by ray.wurlod
The actual syntax will depend on which shell you are scripting for. Typically there's a statement that marks the end of the IF block.

Code: Select all

if [ $prj -eq 'dev' ]
   $path=/dev/pathname
else
   $path=/tst/pathname
fi
Beware of using shell variable names that might be confused with environment variable names such as PATH.

Posted: Fri Jan 18, 2008 6:15 am
by Ush
Thanks for your reply.How can I use this $path variable inside Datastage?

Posted: Fri Jan 18, 2008 6:22 am
by JoshGeorge
You are invited to consider this also: Using C/C++ API (DataStage development kit) build a self-contained program to change the Environment variables.

Posted: Fri Jan 18, 2008 2:56 pm
by ray.wurlod
WHERE inside DataStage? Usually the method for a job is to set up a job parameter that references the environment variable; you can make reference to that job parameter wherever it is appropriate to do so within the job.

Or in a job sequence you can do the same, or you can load the value into a user variable using a User Variables activity.

Posted: Fri Jan 18, 2008 6:30 pm
by Ush
Thanks so much for you replies.$path takes value dynamically.i.e.if its development environment $path takes a value and if its production it takes different value.

$path get effected for Datastage settings.Could please give me more idea on C/C++ API.

Posted: Fri Jan 18, 2008 7:20 pm
by ray.wurlod
Over to you, Joshy...