acessing environment variable in scripts

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
RAJARP
Participant
Posts: 147
Joined: Thu Dec 06, 2007 6:46 am
Location: Chennai

acessing environment variable in scripts

Post by RAJARP »

Hi all,
I am having a unix script which is getting called by a before/after subroutine.The script is just searching for a file like
find home/md/DEV/MIS/LANDING -name MIS_Customer_\*.
But i dont want to hardcode the path in my script.But am having an environment varibale defined in my administartor as
PATH(ie)home/md/DEV/MIS/LANDING .Is there any way to access that environment variable in my shell script ??.or please let me know anyother workaround to achive this.
Please help me
regards,
rajarp
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Pass the value of the environment variable as a command line argument when invoking the script, and pick it up within the script as a shell variable that reads the command line, for example $1.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or seems to me you could just reference it directly in the script - $VariableName or ${VariableName} for example.
-craig

"You can never have too many knives" -- Logan Nine Fingers
UPS
Premium Member
Premium Member
Posts: 56
Joined: Tue Oct 10, 2006 12:18 pm
Location: New Jersey

Post by UPS »

Define variable as job parameter, In the Before/After exec You can use that variable as #variable-name#
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

chulett wrote:Or seems to me you could just reference it directly in the script - $VariableName or ${VariableName} for example.
That would fail if the job parameter had been given a non-default value at run time, which does not change the environment variable value. That's why I thought the indirection was necessary.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, if you've added an Environment Variable as a job parameter and assigned it a non-default value at runtime, then it *is* changed for the duration of the session. So I don't really think it would fail.

Simple enough to test if one felt the urge.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply