On 11/12/06, siegfried <[EMAIL PROTECTED]> wrote:
Is it possible to write a perl script to manipulate the environment variables in a windows CMD.EXE shell?
Yes, if the shell allows it, or if you start the shell yourself.
I need to change the values of environment variables for the parent process.
If your shell's command language allows you to capture the output of a program (as Perl itself does with backquotes) you could use the output of your Perl program to tell the shell which variables to set to what values.
I have a windows bat file and everyday I have to edit it to contain the current date (because I have a batch job that creates a new directory with the current date in the directory name).
Alternatively, you could write your Perl program to edit the bat file, so you wouldn't have to do that manually.
I think the best I could hope for would be to write a perl script that generated a bat file and then I manually execute the bat file. I don't think there is anyway to automate the execution of the bat file.
I'm sure that there is; if you can't put it into its own bat file, you could have Perl itself execute it via the system() command. Since new processes (such as those run with system()) inherit the environment, it's easy to set up %ENV however you'd like. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>