Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permantly Setting AIX enviroment variables from a Perl Script...

Status
Not open for further replies.

juanmj

Technical User
Nov 13, 2001
5
US
Hi...

Does anyone know how to actually, set an ENVIROMENT variable in a Perl script, so that it stays "SET" in the actual OS enviroment once the script is finished running?

Example:
If I use in my script: $ENV{"PATH"}="/foo/folder";

Once the script runs, I want to be able run from AIX command line:

=> echo $PATH
and actually see that it has been set to /foo/folder....

NOTE: I'm aware that once I run the script the env settings it sees are the child ones, and once the cript is finished running those env settings die with it, I WANT A WAY TO GET AROUN THIS!!!!

Thanks....
 
you could write to your rc file..... of course you would have to open a new shell to take advantage of the changes...
 
Not a particularly elegant way, but it will work:
Code:
test.pl:
print "export ABC=123\n";

bash, ksh:
$ eval $(test.pl)
$ echo $ABC
Cheers, Neil :)
 
Hi Neil,

Thanks for your suggestion...
But doing this requires running a separate "ksh" script from command line in the first place to evaluate a prl file...

I would really like to have SYSTEM VARIABLES control starting from a PERL script as the Mother of all my processes... ANd if PERL has to call a ksh script to set system variables that would also be helpful (but so far the only way I know how to do this, creates a copy of Enviroment variables for the child process and does not reflect on Parent process enviroment variables)....

Starting Process: Perl Script!!!
PARENT CHILDREN
-------- ------------
PERL|-> ksh(OS sytem variables editing script) ...
or
|-> prl (OS system variables editing script) ...

Can it be done???

Thanks, JMJ
 
On Solaris, "man export" shows....
"export - ....functions to determine the characteristics for environmental variables of the current shell and its descendents"

So, if AIX behaves similarly, you should be able to set the ENV variable, then export it, and any child process of that Perl code would see it as having been set. However, no other process would. If you want all processes to see it, then you'll have to modify the start-up conditions for your shell as was previously mentioned.

I think... 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top