Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^10: Multi-threads newbie questions

by daverave (Scribe)
on Sep 20, 2010 at 18:53 UTC ( [id://860917]=note: print w/replies, xml ) Need Help??


in reply to Re^9: Multi-threads newbie questions
in thread Multi-threads newbie questions

IPC::System::Simple

p.s. not sure I understand the difference between the normal and the *x versions (e.g. capture vs catpurex). If you do, I'd be happy if you explained ("avoids the shell?")

Replies are listed 'Best First'.
Re^11: Multi-threads newbie questions
by BrowserUk (Patriarch) on Sep 20, 2010 at 19:27 UTC
    I'd be happy if you explained ("avoids the shell?")

    The standard system command will either invoke the program you specify directly, or under some circumstances--eg. When the command line supplied contains shell meta-characters like 'prog > file' or 'prog | someOtherProg' --it will invoke a system shell (sh, csh, bash or cmd.exe) and supply the command line you supplied, to that shell.

    In some quarters, invoking a shell to perform redirection, is seen as something extraordinarily dangerous for some reason. So they leap through hoops in order to avoid invoking a shell.

    For your purposes, you need to invoke a shell in order that you can perform the cd path; prior to running the program, so you need to use capture() not capturex(). However, it also says in the docs that if you supply the arguments to the program as an array, then it will also "avoid the shell".

    Quite frankly, I see no merit is using capture() over qx// for your purpose. Just a lot of extra code and dependency for little or no gain. But, others will disagree with that assessment.


    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.
      Just a lot of extra code and dependency for little or no gain. But, others will disagree with that assessment.

      Better error messages are definitely worth it :)

        Are they better?

        C:\test>perl -MIPC::System::Simple=capture -E"say capture( 'perl', '-q +' )" Unrecognized switch: -q (-h will show valid options). "perl" unexpectedly returned exit value 9 at -e line 1 C:\test>perl -MIPC::System::Simple=capture -E"say capture( 'prel', '-q +' )" "prel" failed to start: "The system cannot find the path specified" at + -e line 1 C:\test>perl -E"say qx[prel -q 2>&1]" 'prel' is not recognized as an internal or external command, operable program or batch file. C:\test>perl -E"say qx[perl -q 2>&1]" Unrecognized switch: -q (-h will show valid options).

        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-03-19 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found