Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: feeding text to a process, and capturing its output, safely

by jonadab (Parson)
on Mar 23, 2004 at 22:21 UTC ( #339229=note: print w/ replies, xml ) Need Help??


in reply to Re: •Re: Re: feeding text to a process, and capturing its output, safely
in thread feeding text to a process, and capturing its output, safely

Will you please comment on the disadvantages of this method?

It depends on where your input is coming from and what it contains, but in the general case, wherein the input *might* contain shell metacharacters and *might* potentially even be constructed with malice, the shell *might* give complete control of your system (or, at least, as much control as is available to the user the code is running as) to whoever constructed the input. More likely, however, a shell metacharacter will get included randomly by someone who is not aware of the implications and cause apparently random breakage. For example, you'll put an ampersand in the input one time without thinking, and Weird Stuff(TM) will happen, and you'll have to track down the problem and figure out that the ampersand needs to be escaped, and so on. This is bad: your program is not robust, and input that's a little different from what was anticipated causes it to unexpectedly fail.

It's also something of a portability nightmare, since different shells have different metacharacters that behave in different ways. This can create all kinds of zany debugging fun.


;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print


Comment on Re: feeding text to a process, and capturing its output, safely

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-07-26 02:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls