setting path in command window using perl

  • Thread starter Amish Rughoonundon
  • Start date
A

Amish Rughoonundon

Hi,
here is my problem. I have a perl script that executes multiple
command line calls as follows:

system("XCOPY", "$s_currentWorkingDirectory\\KCPSM3.EXE",
$s_tempLocation, "/R", "/Y") == 0 or die "File KCPSM3.EXE could not be
copied: $!\n";
system("XCOPY", "$s_currentWorkingDirectory\\ROM_form.coe",
$s_tempLocation, "/R", "/Y") == 0 or die "File ROM_form.coe could not
be copied: $!\n";

This is an example. There are many more with different programs being
called.

My problem is that I need to set the path to a certain batch file
before calling the programs.

It seems everytime I call system though, perl open a command window,
executes the program and closes the window.

So even if I set the path at the beginning, once system is done
running, the path disappears.

Can I force perl to run everything into only 1 command window.

I hope I was clear with my question. Thanks a lot for the help,
Amish
 
J

Jürgen Exner

Amish Rughoonundon said:
here is my problem. I have a perl script that executes multiple
command line calls as follows: [...]
My problem is that I need to set the path to a certain batch file
before calling the programs.

No problem, just do so
$ENV{PATH} = .......
It seems everytime I call system though, perl open a command window,
executes the program and closes the window.

Of course. That is the semantic of system().
So even if I set the path at the beginning, once system is done
running, the path disappears.

Of course. Environment variables are never inherited from the child to
the parent.
Can I force perl to run everything into only 1 command window.

Yes, you could. Just start all your external commands from the same DOS
command line:
system ("cmd1 & cmd2 & cmd3 & cmd4");
But why?


See also "perldoc -q environment":
I {changed directory, modified my environment} in a perl script. How
come the
change disappeared when I exited the script? How do I get my changes
to be visible?

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top