Gavin Henry wrote:
> On Tuesday 31 Aug 2004 01:51, you wrote:
> > 2. The way you're calling system() looks odd. You're using more
> > than one arg, which is a signal to bypass the shell. But your
> > second arg looks like it needs shell processing. Does this actually
> > work? 
> 
> Yup, out of the cookbook.

Odd. Which cookbook?

Here's a simple illustration of what I'm talking about.

Consider a simple command like 

   head /etc/services /etc/protocols

This works, as it passes the command line to the shell for processing

   $ perl -e 'system "head /etc/services /etc/protocols"'

This also works, as I'm splitting the arguments myself:

   $ perl -e 'system "head", "/etc/services", "/etc/protocols"'

But this (which is similar to what you're doing) doesn't work:

   $ perl -e 'system "head", "/etc/services /etc/protocols"'   
   head: /etc/services /etc/protocols: No such file or directory

Since there's more than one argument to system(), the shell is bypassed, and
execve(2) sees a single file name "/etc/services /etc/protocols" instead of
two separate file names. Hence, the error message.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to