Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Set environment variable for one time system command windows

by BrowserUk (Pope)
on Mar 27, 2013 at 19:10 UTC ( #1025791=note: print w/ replies, xml ) Need Help??


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

The problem is that the variable substitution %test% is done before the command is executed. Ie. the variable in the echo is expanded before the set is exectuted.

However, if the second command is an executable rather than a built-in command, the variable is set when the executable runs:

C:\test>set test= & perl -E"system q[set test=fred & perl -E\"say $ENV +{test}\"]" fred

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Set environment variable for one time system command windows
Download Code
Replies are listed 'Best First'.
Re^2: Set environment variable for one time system command windows
by rmahin (Beadle) on Mar 27, 2013 at 19:57 UTC
    Well damn haha, just assumed that since the echo wasn't working the variable was not getting set. Thanks for clarifying.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-28 03:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls