in reply to system, pipes, shell, quoting
To be safe, the values of $program1, $program2, etc. would be "known", drawn from some limited set of alternatives, and the values of $file1, $file2 would be pre-conditioned to eliminate any characters that would cause problems in the shell (esp. semicolons, pipe symbols, ampersands and such) -- either remove them outright or replace them with safe punctuation characters, underscores, or whatever.
But if you need to handle some oddball file names, you might try the following alternative to the system call:
I'm not saying this is guaranteed to work for you, but it's something to try (especially if you were intending to use the system call inside a loop: open the shell before going into the loop, then just print a command line to the shell on each iteration -- see a sample of this in a utility I posted a while ago).$file1 = s/(\W)/\\$1/; # and similarly for other filenames open( SH, "| /bin/sh"); print SH "$program1 $file1 | $program2 | $program3 > $file2\n"; close SH;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: system, pipes, shell, quoting
by superpete (Beadle) on Nov 13, 2002 at 05:22 UTC | |
by graff (Chancellor) on Nov 13, 2002 at 06:14 UTC | |
by superpete (Beadle) on Nov 13, 2002 at 06:48 UTC | |
by superpete (Beadle) on Nov 13, 2002 at 06:59 UTC | |
by superpete (Beadle) on Nov 13, 2002 at 06:24 UTC | |
by superpete (Beadle) on Nov 13, 2002 at 06:39 UTC | |
by graff (Chancellor) on Nov 13, 2002 at 07:22 UTC | |
by superpete (Beadle) on Nov 13, 2002 at 07:42 UTC | |
|
Re: Re: system, pipes, shell, quoting
by hardburn (Abbot) on Nov 13, 2002 at 15:20 UTC |