Bob Showalter said: > 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?
2 and 3: Recipe 16.2 in version ": To avoid the shell, call system with a list of arguments: $status = system($program, $arg1, $arg); die "$program exited funny: $?" unless $status == 0; The returned status value is not just the exit value: it includes the signal number (if any) that the process died from. This is the same value that wait sets $? to. See Recipe 16.19 to learn how to decode this value. > > 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. I get you now. rdiff-backup thinks -v5 --print-statistics in one arg, not two. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>