Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: UNIX environment setup via perl

by haoess (Curate)
on May 07, 2004 at 14:39 UTC ( #351469=note: print w/ replies, xml ) Need Help??


in reply to UNIX environment setup via perl

Yes, your child processes can't put their environment to their parents. What about

$ENV{JAVA_HOME} = '/your/path';

-- Frank


Comment on Re: UNIX environment setup via perl
Download Code
Re: Re: UNIX environment setup via perl
by perlisfun (Sexton) on May 07, 2004 at 14:49 UTC
    PerlIsFun

    This is not what we want. We actually want that environment variable is set after perl script is done/finished.
      This is not possible. Child processes cannot change the environment of its parents. In this case, the perl script cannot alter the environment in the calling shell. You have to use "source" or "." with a shell script instead. Another way is to use the shell-builtin "eval" to evaluate the output of the script. Look at /usr/X11R6/bin/resize for an idea how to use this.

      You can't manipulate environment variables for your parent processes. Why? It's a security concern.

      But: Your shell can use the output of your perl programm to set it's own environment:

      # perl -lw print "export FOO=bar"; # assuming bourne-compatible shell

      Later in your (parent) shell:

      $ eval `your_perl_script.pl` $ echo $FOO bar $

      -- Frank

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://351469]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2014-08-01 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls