use Win32::Process; My output reports 'The system cannot find the path specified'
I am relearning Perl after about 10 years of non use.
I did a copy and paste of the two scripts below from one of the answers for a similar question on this site. I have checked and double checked the path
and tried several deviations, but I still get the same answer -
The system cannot find the path specified
Any help would be greatly appreciated!
It does get to the starting child process
and the exits with the error message The system cannot find the path specified
.
Below is the cut and paste of the original two scripts
parent.pl:
#!/usr/bin/perl
use warnings;
use Win32;
use Win32::Process;
$| = 1;
my $p;
print "S开发者_运维知识库tarting child process ... \n";
Win32::Process::Create(
$p,
'c:\Perl\perl.exe',
'perl hello.pl',
1,
NORMAL_PRIORITY_CLASS,
'.',
) or die Win32::FormatMessage( Win32::GetLastError() );
print "Waiting three seconds before killing 'hello.pl'\n";
for (1 .. 3) {
print;
sleep 1;
}
$p->Kill(0)
or die "Cannot kill '$p'";
hello.pl
#!/usr/bin/perl
$| = 1;
print "Hello World\n";
print "Sleeping 1000 seconds\n";
for (1 .. 1000) {
sleep 1;
print '.';
}
You need to escape the backslashes in your path, or use forward slashes.
Look at this somewhat related post.
(This answer will be edited as conditions check out)
- check that there is a
c:\Perl directory
- it may be case-sensitive (eg.C:\
notc:\
) - make sure there's a
perl.exe
listed in that directory, the actual path might beC:\Perl\bin\perl.exe
'perl hello.pl'
may need to be the full qualified perl path (eg'C:\Perl\perl.exe hello.pl'
)
Side Note:
- Since you're using single-quotes (
'
) you shouldn't need to escape your backslash (\
) - If processing
on windows you may change:
#!/usr/bin/perl
to the specified windows path#!C:\Perl\perl.exe
, however I don't think this really matters as much on windows, it just helps you know where the executable is for times like this.
精彩评论