in reply to Re: UNIX environment setup via perl
in thread UNIX environment setup via perl

PerlIsFun

This is not what we want. We actually want that environment variable is set after perl script is done/finished.
  • Comment on Re: Re: UNIX environment setup via perl

Replies are listed 'Best First'.
Re: Re: Re: UNIX environment setup via perl
by eserte (Deacon) on May 07, 2004 at 15:01 UTC
    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.
Re: Re: Re: UNIX environment setup via perl
by haoess (Curate) on May 07, 2004 at 15:05 UTC

    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