I did not say it solved your problem; I said that it shows how you can accomplish this.
It sounds like the easiest solution (given that you are so reluctant to admit that you can read the contents of your setEnv.bat) would be to add "call setEnv.bat" to the preamble that pl2bat would add to your Perl script.
| [reply] |
Thanks for the reply. How can I include "call setEnv.bat" inside a subroutine of perl - the pl2bat sure generated a .bat file, but the subroutines are still subroutines right? Can I just stick in a statement "call setEnv.bat" inside a subroutine in the generated bat file?
| [reply] |
How can I include "call setEnv.bat" inside a subroutine of perl
Read more carefully? 'add "call setEnv.bat" to the preamble'
If having the environment variables always set is a problem, then "you can't get there from here".
| [reply] |
| [reply] |
If I invoke the batch file from inside another batch file - I can do this. Lets say I have batch2.bat the inside of which looks like:
@echo off
set TEST_ENV=true
I have another batch file setEnv.bat the inside of which looks like:
@echo off
call batch2.bat
after executing setEnv.bat on command line
if I do "set TEST" it will print: TEST_ENV=true
The same thing if I do from perl like :
my $cmd = "call setEnv.bat";
system( $cmd );
and call the perl script from command line.
then do "set TEST"
It will print : "Environment variable TEST not defined"
| [reply] |
If I invoke the batch file from inside another batch file - I can do this.
Yes. Because running a batch file from another batch file does not start a new process. cmd.exe is the batch processor, so the changes are made to the current process' environment; and when you exit the called batch file, you are still running under the auspices of that same process. Hence, you can see the changes.
But, when you call a batch file from perl, perl has to start a copy of cmd.exe to execute it; so the changes are made to cmd.exe's copy of the environment, but as soon you return to perl, that process and its environment is thrown away and you return to the same environment you had before you started that child process.
What you are trying to do is impossible.
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.
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |