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

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!coplex!trebor!root
  3. From: root@trebor.uucp (Bob Stockler)
  4. Subject: Re: Am I writing to a tty or pipe?
  5. Organization: Bob Stockler
  6. Date: Fri, 13 Nov 1992 23:27:24 GMT
  7. Message-ID: <1992Nov13.232724.2609@trebor.uucp>
  8. References: <228@dinowine.huber.com>
  9. Lines: 20
  10.  
  11. eddjp@dinowine.huber.com (Dewey Paciaffi) writes:
  12.  
  13. >Is there a way to determine from within a Bourne shell script if
  14. >the output is being written to a tty or a pipe?
  15.  
  16. If the script is written to perform as a filter (i.e.: gets input
  17. from its standard input, writes to its standard output), or as a
  18. program that does whatever it does and writes everything to its
  19. standard output, I'd say "no" to the question.
  20.  
  21. It is a child (or subshell) of the shell that's executing it, and
  22. is simply writing to its file descriptor #1, and the parent shell
  23. is causing the output from the script to be, or not be, redirected
  24. anywhere that has been specified by some mechanism in the parent.
  25.  
  26. There are ways, within a script, to assure how and where its output
  27. should go (either one, or multiple directions) according to how it's
  28. invoked, but I know of no way for a script to tell - outside of its
  29. own internal redirections - where its output is going.
  30.  
  31.