Operating System - HP-UX
1826214 Members
3135 Online
109691 Solutions
New Discussion

Re: Problem with Exporting a varaible from shell script

 
Dinesh Reddy
New Member

Problem with Exporting a varaible from shell script

Hi all,

I am having the below problem in my HPUX machine.

I have an Shell script which is having some automation code. The code has a line like below.

PROJECT=MIT
export PROJECT

After running the above script I have to run one more script in which PROJECT variable will be used. But at this point I am getting blank value for PROJECT variable.

But when I set that variable from $ prompt, then it is working fine. I have tried as administrator also.

Could anyone help me to solve the above problem.
3 REPLIES 3
Arunvijai_4
Honored Contributor

Re: Problem with Exporting a varaible from shell script

http://www.tinker.ncsu.edu/LEGO/shell_help.html

Please refer this link, it should helpful

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Eric SAUBIGNAC
Honored Contributor

Re: Problem with Exporting a varaible from shell script

Hi,

it's a normal behavior : when you call a script from the command line a new shell is invoked to execute it. So the environnement wich you modify is that of the new shell.

To have current shell environnement modified by your script, simply invoke it with . (point)

For exemple, if your script's name is foo, and you are in the directory where foo reside, type :

. ./foo

Or if foo is /tmp/foo, type :

. /tmp/foo

Hope this will help

Eric

(PBFWME;)
Dinesh Reddy
New Member

Re: Problem with Exporting a varaible from shell script

Hi Guys,

Thanks for your help. Now I could able to find the solution to my problem.

Thanks for your assistance.

Dinesh