http://www.perlmonks.org?node_id=973951


in reply to Re: autodie and IPC::System::Simple on Windows
in thread autodie and IPC::System::Simple on Windows

Better answers?

It says "dir" failed to start: "The system cannot find the file specified

It is lookin for a file dir and it can't find it, there is no dir.exe on win32

  • Comment on Re^2: autodie and IPC::System::Simple on Windows

Replies are listed 'Best First'.
Re^3: autodie and IPC::System::Simple on Windows
by BrowserUk (Patriarch) on Jun 02, 2012 at 08:24 UTC

    It is wrongly assuming that dir is an executable when it is actually a cmd.exe built-in.

    Use the built-in system and that does not happen.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Bingo! Now it all makes sense to me. Apparently Perl's internal "system" takes this into account. Indeed, with both autodie and IPC::System::Simple loaded, this works just fine for me:

      systemx('cmd', '/c', 'dir', 'test.pl');

      Thanks for steering me in the right direction.

        I do not see anything in the Windows specific notes you linked to that documents when, or even if it tries, to distinguish shell built-in commands from external executables?

        Unless you include "The capture subroutine always returns the 32-bit exit value under Windows. The capture subroutine also never uses the shell, even when passed a single argument.", which seems like a very ... um .. short-sighted policy.

        Whilst there are a few specific time when you want to avoid using the shell for application specific pragmatic reasons; doing so at all times and at all costs is dogmatic and unjustifiable.

        This is another of those occasions where IMO, the attempt to provide cross-platform compatibility is being applied at too low a level. The way OSs, and particularly shells, do their thing is necessarily sufficiently different, that trying to abstract at that level is bound to end in unacceptable compromises at best; and unworkable failure the rest of the time.

        The alternative is that programs abstract system calls at a higher level. That is, at the 'perform this particular OS function" level:

        my $resultFromExternalSource; if( $^O eq 'MSWin32' ) { $resultFromExternalSource = win32GetFromExternalSource( ... ); } elsif( $^O eq 'linux' ) { $resultFromExternalSource = linuxGetFromExternalSource( ... ); } elsif( $^O eq 'VMS' ) { $resultFromExternalSource = ...; } elsif ...

        The lower the level you try to abstract something at, more more likely the 'lowest-common-denominator' requirement will compromise the possibilities.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?