develooper Front page | perl.beginners | Postings from January 2002

How to export environment variables in Win32

Thread Next
From:
Adriano Rodrigues Ferreira
Date:
January 31, 2002 10:00
Subject:
How to export environment variables in Win32
Message ID:
NJOURTPUFBQLIG1YNHLKPM326PL.3c5986df@inf-10

I thought it would be a good idea to replace a batch script
(.bat) running on a Windows 2000 with a Perl script which
is far more clever. 

The original batch file setted two environment variables
which were available after running the script. That is,
if I did
c:> cvs-init.bat

it has commands like
     set CVSROOT=:pserver:user@aCVSserver:/usr/local/cvsroot

and then I could verify

c:> set CVSROOT
CVSROOT=:pserver:user@aCVSserver:/usr/local/cvsroot

To set environment variables in Perl, I first tried 'system' calls.
They worked but the environment variables were reset to the
previous values after the script ended.

I tried the Env module. The same result.

What it is missing is something to export the environment
variables to the outer shell executing the Perl interpreter.
Just like what is done in Unix by a command like

$ . ./cvs-init.pl

Is it possible in Win32?

Best regards,

Adriano.





Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About