Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!ccut!wnoc-tyo-news!astemgw!choshi!frf!yang From: yang@nff.ncl.omron.co.jp (YANG Liqun) Newsgroups: comp.unix.programmer Subject: Re:How to determine the destination of standard output? Message-ID: Date: 8 Feb 91 05:36:38 GMT Sender: news@frf.omron.co.jp Distribution: comp Organization: OMRON Corp., Kyoto, Japan Lines: 26 writes: >I'm not sure if this subject has be discussed before. I want to know >if there is a way to tell within a program where its standard output >goes. More specifically, if the output goes to the terminal screen, or >goes to a pipe, or is redirected into a disk file. Thanks for any info. If you want to if the standard output is terminal, use ttyname() or isatty. Otherwise, use #include #include fstat(fd, buf) int fd; struct stat *buf; check buf->st_mode. -- ------------------------------------------------------------------------------- | Yang Li-qun | | OE, OMRON Corporation | | 20, Igadera Shimokaiinji Nagaokakyo-City | | Kyoto 617 Japan | | Tel: 075-951-5111 Fax: 075-956-7403 | | E-mail:yang@nff.ncl.omron.co.jp | -------------------------------------------------------------------------------