Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Changing a unix users environment

by suaveant (Parson)
on Oct 25, 2007 at 13:02 UTC ( [id://647163]=note: print w/replies, xml ) Need Help??


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 >

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-25 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found