Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

autodie and IPC::System::Simple on Windows

by JohnRS (Scribe)
on Jun 02, 2012 at 04:29 UTC ( [id://973936]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks. I seek your wisdom.

I'm writing a program on Windows 7 using Strawberry Perl 5.12.3. I'm having a problem using two modules which give me no trouble on Linux.

IPC::System::Simple (v1.21) doesn't seem to work.

use IPC::System::Simple qw(capture capturex system systemx run runx $E +XITVAL EXIT_ANY); # This fails. system('dir', 'test.pl');

autodie (v2.11) uses IPC::System::Simple, but if (and only if) you have explicity loaded IPC::System::Simple, then you can avoid the problem by temporarily disabling autodie. But you also lose the advantage of having it, at least while it is disabled.

use autodie 'system'; # This works. no autodie 'system'; system('dir', 'test.pl'); use autodie 'system'; # This fails. system('dir', 'test.pl');

The error I'm seeing is: "dir" failed to start: "The system cannot find the file specified" at C:/strawberry/perl/vendor/lib/IPC/System/Simple.pm line 480.

According to CPAN both these modules are supposed to work on Windows and are widely used. So I'm guessing that there is something that I'm overlooking. I did try the tests on another Windows machine and got the same results.

Thanks, John

P.S. autodie's lexical feature doesn't seem to work on Windows, also. I didn't try it on Linux.

Replies are listed 'Best First'.
Re: autodie and IPC::System::Simple on Windows
by cztmonk (Monk) on Jun 02, 2012 at 11:33 UTC

    This works for Windows 7,64 bit, ActiveState Perl v5.14.2 :

    use IPC::System::Simple qw(capture capturex system systemx run runx $E +XITVAL EXIT_ANY); # This works. system('dir test.pl');

      Same here. Very interesting. As long as I feed it the command and argument as one string, rather than two, it works. Thanks!

Re: autodie and IPC::System::Simple on Windows
by Anonymous Monk on Jun 02, 2012 at 07:31 UTC
Re: autodie and IPC::System::Simple on Windows
by BrowserUk (Patriarch) on Jun 02, 2012 at 08:05 UTC

    Given that both modules are by the same author, you'd probably get better answers by raising the issue(s) with him directly.

    From my perspective, 600 lines of code for "producing a well-formatted error string", seems excessive and unnecessary.

    Adding another 1000+ lines of code in order to avoid typing  ... or die $!; just seems gratuitous.


    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?

      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

        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?

      Yes and no. Comparing apples to apples, from purely a typing perspective: Using autodie is 1 line of typing to save numerous "... or die" lines throughout my code. And I don't have to worry about missing one. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://973936]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-24 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found