home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / perl / 7632 < prev    next >
Encoding:
Text File  |  1992-12-30  |  1.2 KB  |  42 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!florida!essbaum
  3. From: essbaum@rchland.vnet.ibm.com (Alexander Essbaum)
  4. Subject: fork and STDOUT
  5. Sender: news@rchland.ibm.com
  6. Message-ID: <1992Dec30.223911.16297@rchland.ibm.com>
  7. Date: Wed, 30 Dec 1992 22:39:11 GMT
  8. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  9. Nntp-Posting-Host: florida.rchland.ibm.com
  10. Organization: IBM Rochester
  11. Lines: 29
  12.  
  13. easy question (i hope):
  14.  
  15. i'm doing
  16.  
  17. if (!($pid = fork)) {
  18.     open (cmd,"$cmd|");   # $cmd is a call to another perl script
  19.     print <cmd>;
  20.     exit 0;
  21. }
  22.  
  23. the stuff returned in <cmd> (which comes from print "..."; and `...`; lines
  24. in $cmd) doesn't print properly.  it seems to be getting buffered such that
  25. when $cmd exits, all of STDERR gets printed, then all of STDOUT.  i've
  26. read the manual on open and i tried
  27.  
  28. select(STDERR); $| = 1;
  29. select(STDOUT); $| = 1;
  30.  
  31. in several places (both in the command called by $cmd and in the parent
  32. process).  no dice.  i don't really understand what's up with stuff like
  33.  
  34. open (something,">&STDOUT");
  35.  
  36. can someone explain exactly what this does (what is "duping"?) or maybe
  37. point me where to look (i checked the FAQ)?
  38.  
  39. thanx!
  40.  
  41. axel
  42.