Dynamically Setting Environment variables

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
Ush
Participant
Posts: 55
Joined: Tue Dec 04, 2007 3:15 am

Dynamically Setting Environment variables

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ush
Participant
Posts: 55
Joined: Tue Dec 04, 2007 3:15 am

Post by Ush »

Thanks for your reply.How can I use this $path variable inside Datastage?
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post 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.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ush
Participant
Posts: 55
Joined: Tue Dec 04, 2007 3:15 am

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Over to you, Joshy...
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply