Prev: Makefile.PL / ExtUtils::MakeMaker refuses to pick up files in /bin
Next: FAQ 3.10 Is there an IDE or Windows Perl Editor?
From: Amish Rughoonundon on 9 Aug 2010 16:41 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
From: Sherm Pendley on 9 Aug 2010 17:02 Amish Rughoonundon <amishrughoonundon(a)gmail.com> writes: > here is my problem. I have a perl script that executes multiple > command line calls .... > Can I force perl to run everything into only 1 command window. Sure, just write all of the commands to a batch file, then use a single system() call to run that batch file. sherm-- -- Sherm Pendley <camelbones.sourceforge.net> Cocoa Developer
From: Ben Morrow on 9 Aug 2010 18:50 Quoth Amish Rughoonundon <amishrughoonundon(a)gmail.com>: > 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. What do you mean by 'set the path to a batch file'? Do you mean adding an entry to %PATH%? You can do this by adding to $ENV{PATH} from Perl; the environment in %ENV will be inherited by all the commands you run with system. Ben
From: J�rgen Exner on 9 Aug 2010 21:40 Amish Rughoonundon <amishrughoonundon(a)gmail.com> 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
From: Ben Morrow on 9 Aug 2010 23:42
Quoth J�rgen Exner <jurgenex(a)hotmail.com>: > > 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? This is actually the inverse problem: "I modified my environment with system(). How come the change disappeared when I got back to Perl?". The answer is the same, of course, but it's not entirely surprising the OP didn't find it. Ben |