rovf has asked for the wisdom of the Perl Monks concerning the following question:

Occasionally (not reproducible so far) I see from the logs that a task fails to do a IPC::Run::run on Windows, giving the error message

No such file or directory: Win32::Process::Create()

The command to be executed looks like this (according to the debugging log just before the run()):

run(['C:\\my\\path\\to\\perl.exe','-w',....]);
As I said, in nearly all cases this succeeds. From the error message I would conclude that run() does not find perl.exe, but when I do a DIR, the Perl.exe is there. Also it is on C: drive, which means that it hardly won't go away for a while and come back later, as it would maybe be possible if it were on a network drive.

So my question is: Are there other circumstances that run() yells the aforementioned error message, other than the program to be executed not being found? Well, I guess if CMD is not found, the behaviour might be the same, but here too it is not obvious why CMD should suddenly be gone for a while.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re: Weird message from IPC::Run::run
by repellent (Priest) on Mar 19, 2009 at 18:42 UTC
    It could be due to the arguments that come after '-w'.

    I'm skeptical about the escape-quoting mechanism in the source:
    my $process; my $cmd_line = join " ", map { ( my $s = $_ ) =~ s/"/"""/g; $s = qq{"$s"} if /[\"\s]/; $s; } @$cmd; _debug "cmd line: ", $cmd_line if _debugging; Win32::Process::Create( $process, $cmd->[0], $cmd_line, 1, ## Inherit handles NORMAL_PRIORITY_CLASS, ".", ) or croak "$!: Win32::Process::Create()";

    Perhaps this may be better to make it seem more Unix-like:
    my $cmd_line = join " ", map { (my $s = $_) =~ s/([\\"])/\\$1/g; qq{"$s"}; } @$cmd;

    BTW, thanks for writing Windows quoting.
      It could be due to the arguments that come after '-w'

      If this would be the reason, I think it should fail every time, and not run well most of the time. There are actually two arguments after the -w: The first is a Windows UNC path, and the second is just a word. Aside from the path separators, only letters and digits are used in the arguments. Nothing dangerous about quoting anyway.

      The error message seems to be generated pretty late. I am using redirection, i.e.

      run([....],'>output','2>error');
      and the error message of run() is found in the output file, which means that it is generated after run() has set up the redirection. I don't know whether this gives us some clue though....

      -- 
      Ronald Fischer <ynnor@mm.st>