Home: Perl Programming Help: Intermediate:
Avoiding shell escapes

New User

Mar 6, 2002, 1:30 AM

Views: 832
Avoiding shell escapes

I'm using Perl v5.6.1 under WinNt 4.0 in a Dos box.
Inside the Perl script, I need to call a batch file (<name>.bat), which sets all kinds of things - what it actually does is beyond my scope. I need those settings to continue with my own Perl script.

My problem: this batch file is invoked in a different shell, i.e. all the environment settings are copied, and using this copy, the batch file is executed. It is also on that copy that changes are made. When the program ends, the copy is destroyed, leaving Perl with an unmodified environment, which is, in this case, highly indesirable.

Is there any way to circumvent this, I mean, to let the batch file make the changes on the same environment as my Perl script uses?


Mar 6, 2002, 6:18 AM

Views: 824
Re: [Haplo2] Avoiding shell escapes

I don't know. Any changes to the environment in child processes, will only be visible in that process (and it's child processes).

However, do you really need that batch file? Perl has been introduced for many reasons, also to replace UNIX shell scripts. Windows batch files are far more limited, so I expect you can rewrite that in Perl aswell.

So please post that batch file code. I can't help you with anything else here.

Yet Another Perl Programmer

~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool