home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!convex!convex!tchrist
- From: tchrist@convex.COM (Tom Christiansen)
- Newsgroups: comp.lang.perl
- Subject: Re: open - Does it use the shell?
- Keywords: open, shell
- Message-ID: <1992Jul27.145308.4695@news.eng.convex.com>
- Date: 27 Jul 92 14:53:08 GMT
- References: <1992Jul27.100134.20233@neptune.inf.ethz.ch>
- Sender: usenet@news.eng.convex.com (news access account)
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- Organization: CONVEX Realtime Development, Colorado Springs, CO
- Lines: 36
- Originator: tchrist@pixel.convex.com
- Nntp-Posting-Host: pixel.convex.com
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
-
- From the keyboard of weingart@inf.ethz.ch:
- :Yo, perl dudes and dudettes!
- :
- :I have a small perl script, which amounts to roughly:
- :
- :$args = join(' ', @ARGV);
- :$prog = './someperlprog';
- :open(FOOBAR, "$prog $args -xxx -xxx |");
- :chop( @DATA = <FOOBAR> );
- :foreach $i (@DATA){
- :...
- :}
- :
- :Ok, the prob is this, the open seems to invoke the
- :shell. Yes, there are meta-chars in $args, but $prog
- :exists. Does open always invoke the shell on meta chars?
- :
- :There has got to be a better way than to doubly escape,
- :or quote everything.
-
- Indeed.
-
- If $args contains metacharacters, and you don't want
- the shell intervening for the above command, do this:
-
- open(FOOBAR, "-|") || exec $prog, $args, ("-xxx") x 2;
-
- And don't forget your error checking.
-
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
-
-
- "We don't care. We don't have to. We're the Phone Company."
-