Hi, I'm having a lot of trouble with the Win32::Spawn module in perl. Here is my situation, I have a Win32::Spawn call which looks like this:
-
my $success = undef;
-
my $cmdline = EBDTools::os_path("${nh_home}/web/aview/modules/svcrsp-ng/saSync.pl");
-
-
$success = Win32::Spawn($^X, "${^X} $cmdline ${optfile}", $pid);
-
if (! $success) {
-
my $lasterr = Win32::GetLastError();
-
return_configerror("Failed to create commit / sync process (${lasterr}): ${^X} ${cmdline}");
-
}
-
Basically what this does is spawn a new process to call perl and execute saSync.pl. Inside saSunc.pl I am trying to run an internal binary called "helloworld.bat" which has the contents:
-
echo helloworld > c:\helloworld.txt
-
Obviously I am just checkign to see that this actually works. Well I've tried everything, I've tried using back ticks (`c:\mypath\helloworld.bat`), another Win32::Spawn (i.e as follows )
-
my $success = Win32::Spawn('d:\\eHealth60\bin\helloworld.bat', undef, $pid);
-
if (! $success) {
-
my $lasterr = Win32::GetLastError();
-
my $msg = Win32::FormatMessage($lasterr);
-
Log("medium", "helloworld failed to execute. Reason = $msg.", $Log::LOG_CALLER_NAME);
-
}
-
Nothing works. c:\helloworld.txt is not getting created which makes me believe that event tough the Win32::Spawn works with executing it is not actually running helloworld.bat. This is driving my BATTY!
Can anyone help me with this? Does anyone have another method for me to try because ultimately what I require is a process spawned by Win32::Spawn to call another batch file / binary on a sytem and either write the output to a file so after the Win32::Spawn I can retrieve the value or if I could call using back tick (' ') I could then receive the value of the batch file / binary back to my executing program.
Any and all help is greatly appreciated. I no nothing else to try :(
Thanks, -Andy