Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Set shell environment variables from within a perl script

by rovf (Priest)
on May 05, 2008 at 17:06 UTC ( [id://684695]=note: print w/replies, xml ) Need Help??


in reply to Set shell environment variables from within a perl script

In the way you were doing it, the environment variable would be gone when the system() call ended (since it was set only in the subshell). You have (at least) two options:

ENV{CVSROOT}="...";
This would also change the environment of your perl program itself, and would hence be propagated to all other child processes; most likely, this is what you want to do in the special case of CVSROOT, isn't it?

The other possibility (assuming that you always shell out to bash, or ksh, or zsh), would go like this: Assume that you want to call an external program myprog with CVSROOT set to a special value, you could use

system('CVSROOT="...." myprog myarguments');
This is useful if you want the change of the environment only for that particular call.

-- 
Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-19 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found