Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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

Replies are listed 'Best First'.
Re: Re: UNIX environment setup via perl
by perlisfun (Sexton) on May 07, 2004 at 14:49 UTC

    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 `` $ echo $FOO bar $

      -- Frank

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (17)
As of 2016-10-26 18:25 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (345 votes). Check out past polls.