in reply to Re^3: Getting the ENV from the .bat file
in thread Getting the ENV from the .bat file

I tried with the following code, $res = get_login_env(); print $res; sub get_login_env { local %ENV; my $env = `echo env | perl -e 'exec {"C:\\temp\\test.bat"} -sh'`; print $env; if (wantarray) { my @pieces = ($env =~ m/^(.*?)=((?:^\n\\|\\.|\\\n)*)/gm ); s/\\(.)/$1/g foreach @pieces; return @pieces; } else { return $env; } } Where the test.bat file is having the set commands. It is not throwing error and it is not getting the varible also.
  • Comment on Re^4: Getting the ENV from the .bat file

Replies are listed 'Best First'.
Re^5: Getting the ENV from the .bat file
by Corion (Patriarch) on Feb 18, 2009 at 15:27 UTC

    That is because you don't have a env command on Windows, and the Windows shell uses double quotes for quoting, and many other things. You need to change the snippet to respect Windows conventions.

    Also, you may want to put your code in between <code>...</code> tags so it renders and downloads nicely.