Page 1 of 1

acessing environment variable in scripts

Posted: Thu Jan 17, 2008 10:56 pm
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

Posted: Fri Jan 18, 2008 5:38 am
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.

Posted: Fri Jan 18, 2008 8:41 am
by chulett
Or seems to me you could just reference it directly in the script - $VariableName or ${VariableName} for example.

Posted: Fri Jan 18, 2008 1:08 pm
by UPS
Define variable as job parameter, In the Before/After exec You can use that variable as #variable-name#

Posted: Fri Jan 18, 2008 3:25 pm
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.

Posted: Fri Jan 18, 2008 3:53 pm
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.