|
Safe Shell Escapes
|
Andy_-@wiwb.uscourts.gov
|
Jun 09, 2004 11:38 PDT
|
Just checked out the FMTEYEWTK site
http://www.perl.com/doc/FMTEYEWTK/
and found this on safe shell escapes in perl:
...
Because there is no way with backticks or popens to tell not to call
the stupid shell and open up your front door to pillaging.
Instead you need this:
if (open(PROGRAM, "-|")) {
@lines = <PROGRAM>;
close PROGRAM;
if ($?) { warn "PROGRAM didn't exit nicely: $?" }
} else {
exec("program", $arg1, @list) || die "can't exec program: $!";
}
Er, how does that work?
a
Andy Bach, Sys. Mangler
Internet: andy_-@wiwb.uscourts.gov
VOICE: (608) 261-5738 FAX 264-5932
Beware of bugs in the above code; I have only proved it correct, not tried
it. -- Donald Knuth
|
|
 |
|