home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4977 < prev    next >
Encoding:
Internet Message Format  |  1992-07-27  |  1.6 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!convex!convex!tchrist
  2. From: tchrist@convex.COM (Tom Christiansen)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: open - Does it use the shell?
  5. Keywords: open, shell
  6. Message-ID: <1992Jul27.145308.4695@news.eng.convex.com>
  7. Date: 27 Jul 92 14:53:08 GMT
  8. References: <1992Jul27.100134.20233@neptune.inf.ethz.ch>
  9. Sender: usenet@news.eng.convex.com (news access account)
  10. Reply-To: tchrist@convex.COM (Tom Christiansen)
  11. Organization: CONVEX Realtime Development, Colorado Springs, CO
  12. Lines: 36
  13. Originator: tchrist@pixel.convex.com
  14. Nntp-Posting-Host: pixel.convex.com
  15. X-Disclaimer: This message was written by a user at CONVEX Computer
  16.               Corp. The opinions expressed are those of the user and
  17.               not necessarily those of CONVEX.
  18.  
  19. From the keyboard of weingart@inf.ethz.ch:
  20. :Yo, perl dudes and dudettes!
  21. :
  22. :I have a small perl script, which amounts to roughly:
  23. :
  24. :$args = join(' ', @ARGV);
  25. :$prog = './someperlprog';
  26. :open(FOOBAR, "$prog $args -xxx -xxx |");
  27. :chop( @DATA = <FOOBAR> );
  28. :foreach $i (@DATA){
  29. :...
  30. :}
  31. :
  32. :Ok, the prob is this, the open seems to invoke the
  33. :shell.  Yes, there are meta-chars in $args, but $prog
  34. :exists.  Does open always invoke the shell on meta chars?
  35. :
  36. :There has got to be a better way than to doubly escape,
  37. :or quote everything.
  38.  
  39. Indeed.
  40.  
  41. If $args contains metacharacters, and you don't want
  42. the shell intervening for the above command, do this:
  43.  
  44.     open(FOOBAR, "-|") || exec $prog, $args, ("-xxx") x 2;
  45.  
  46. And don't forget your error checking.    
  47.  
  48.  
  49. --tom
  50. -- 
  51.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  52.  
  53.  
  54.     "We don't care.  We don't have to.  We're the Phone Company."
  55.