in reply to Changing a unix users environment

if you want to use a Perl script to change your current shell environment you basically have to make a shell script that evals the output of the Perl script, then source the shell script (or run the eval manually).

Something like:

#!perl print "setenv FOO bar\n";
shell script would have...
eval `perl_script.pl`
or whatever... is a pain since you still need to output shell commands, and may or may not need to semi-colon separate them...

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re^2: Changing a unix users environment
by bdimych (Monk) on Oct 26, 2007 at 09:29 UTC
    the same
    ~/bdimych >cat x.pl #!/usr/bin/perl print "eval export \"MYENVVAR=MY ENV VALUE3\";\n"; print ": : If you see this, then you launch this script in wrong way : You should launch it only backslashed i.e. `$0` : See \"Command Substitution\" in man bash : "; ~/bdimych >echo $MYENVVAR ~/bdimych >./x.pl eval export "MYENVVAR=MY ENV VALUE3"; : : If you see this, then you launch this script in wrong way : You should launch it only backslashed i.e. `./x.pl` : See "Command Substitution" in man bash : ~/bdimych >`./x.pl` ~/bdimych >echo $MYENVVAR MY ENV VALUE3 ~/bdimych >