home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / shell / 4587 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.8 KB  |  45 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!dkeisen
  3. From: dkeisen@leland.Stanford.EDU (Dave Eisen)
  4. Subject: Re: How to redirect outputs from the command "time" into a file? 
  5. Message-ID: <1992Nov7.184411.15962@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: Sequoia Peripherals, Inc.
  8. References: <1992Nov5.024837.6571@cs.tulane.edu> <fish.720983465@news2.gsfc.nasa.gov> <1992Nov6.231410.28155@ccd.harris.com>
  9. Date: Sat, 7 Nov 92 18:44:11 GMT
  10. Lines: 33
  11.  
  12. In article <1992Nov6.231410.28155@ccd.harris.com> zhu@controls.ccd.harris.com (Gary Zhu) writes:
  13. >
  14. >In article <fish.720983465@news2.gsfc.nasa.gov>, fish@daacdev1.stx.com writes:
  15. >|> 
  16. >|> time puts its output on stderr (not noted in any man page i've
  17. >|> ever seen either) so:
  18. >|> time a.out 2>a.time
  19.  
  20. >Almost got it.
  21. >"time"  will consider the rest of the line as a whole, so
  22. >time a.out 2>a.time
  23. >will be interpreted as :  run  "a.out 2>a.time"  and report the
  24. >running time of "a.out 2>a.time".
  25. >
  26. >SOLUTION :    (time  a.out) 2>a.time
  27.  
  28. Fish was right. Assuming a Bourne-like shell (he did use the 2>a.time
  29. Bourne syntax), time couldn't possibly report the running time of the
  30. redirected command because the redirection would occur before /bin/time
  31. was called.
  32.  
  33. Of course, all of this changes if time is a shell builtin, like it
  34. is in csh and tcsh and probably some others. Then time can (and in 
  35. the case of csh does) time the redirected command and your answer
  36. would be correct if csh used the 2>a.time syntax for redirection.
  37.  
  38.  
  39.  
  40. -- 
  41. Dave Eisen                               Sequoia Peripherals: (415) 967-5644
  42. dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
  43.        There's something in my library to offend everybody. 
  44.           --- Washington Coalition Against Censorship
  45.