home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / question / 10158 < prev    next >
Encoding:
Text File  |  1992-08-18  |  1.8 KB  |  51 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!ibmpcug!dylan
  3. From: dylan@ibmpcug.co.uk (Matthew Farwell)
  4. Subject: Re: csh and redirect of stderr
  5. Organization: The IBM PC User Group, UK.
  6. Date: Tue, 18 Aug 1992 18:49:06 GMT
  7. Message-ID: <Bt709v.B6u@ibmpcug.co.uk>
  8. Keywords: csh, stderr
  9. References: <1992Aug18.115253.10164@neptune.inf.ethz.ch>
  10. Lines: 39
  11.  
  12. In article <1992Aug18.115253.10164@neptune.inf.ethz.ch> weingart@inf.ethz.ch writes:
  13. >Ok, I though me a wiz, and now here I am stuck.  Well, theoretically
  14. >I could pull down the sources, and read/muck about, but I simply
  15. >don't have the time/patience/space to do that right now.
  16. >
  17. >If some kind soul could email me how to do the following in
  18. >csh, I would be gratefull.
  19. >
  20. >./someprog foobar 2>/tmp/stderr-out 1>/tmp/stdout-out
  21.  
  22. This is how you do it in csh.
  23.  
  24. sh -c "./someprog foobar 2>/tmp/stderr-out 1>/tmp/stdout-out"
  25.  
  26. >Somehow, >& does not seem to do it.... ;-}
  27.  
  28. No it doesn't do it.  You can't do it in csh.  Full stop.  You could try
  29. reading the FAQ for comp.unix.questions, specifically question 2.9
  30. which, as it happens is entitled - This is not a flame btw:
  31.  
  32. 9)  How do I redirect stdout and stderr separately in csh?
  33.  
  34.     In csh, you can redirect stdout with ">", or stdout and stderr
  35.     together with ">&" but there is no direct way to redirect
  36.     stderr only.  The best you can do is
  37.  
  38.         ( command >stdout_file ) >&stderr_file
  39.  
  40.     which runs "command" in a subshell;  stdout is redirected inside
  41.     the subshell to stdout_file, and both stdout and stderr from the
  42.     subshell are redirected to stderr_file, but by this point stdout
  43.     has already been redirected so only stderr actually winds up in
  44.     stderr_file.
  45.  
  46.     Sometimes it's easier to let sh do the work for you.
  47.  
  48.     sh -c 'command >stdout_file 2>stderr_file'
  49.  
  50. Dylan.
  51.