Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Set environment variable for one time system command windows

by aitap (Deacon)
on Mar 27, 2013 at 19:41 UTC ( #1025798=note: print w/ replies, xml ) Need Help??


in reply to Set environment variable for one time system command windows

Since running a command requires a separate process, fork it and set the environment variable via %ENV, then exec your program:

if (fork == 0) { local $ENV{myvariable} = "test"; exec("echo ".($^O eq "MSWin32" ? "%myvariable%" : '$myvariable')) or +die "exec: $!\n"; } __END__ text
Sorry if my advice was wrong.


Comment on Re: Set environment variable for one time system command windows
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-07-30 12:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (231 votes), past polls