Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by Anonymous Monk
on Jun 02, 2012 at 08:15 UTC ( #973951=note: print w/ replies, xml ) Need Help??


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
Re^3: autodie and IPC::System::Simple on Windows
by BrowserUk (Pope) 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?

        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?

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://973951]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2014-10-21 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (106 votes), past polls