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