Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > setting path in command window using perl

Reply
Thread Tools

setting path in command window using perl

 
 
Amish Rughoonundon
Guest
Posts: n/a
 
      08-09-2010
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

 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      08-10-2010
Amish Rughoonundon <(E-Mail Removed)> wrote:
>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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting 'Path' in Windows XP (and path length) DW Computer Support 7 01-03-2011 07:29 PM
suppress opening command window after using os.system command boriq Python 4 06-12-2008 10:42 AM
Is it possible to open a new IE window using a perl command? Paul Perl Misc 5 12-07-2005 11:49 AM
Pull out only first field of ps command ( in Perl ) PERL RUN COMMAND tweetiebirds@gmail.com Perl Misc 2 03-26-2005 06:03 AM
Timing Issue - Setting Title of IFrame Modal Dialog Window Using the Contained Window Title Russell Javascript 2 09-13-2004 12:57 PM



Advertisments