Xref: utzoo comp.unix.questions:11914 comp.unix.xenix:5140 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!gatech!gitpyr!stat!curci From: curci@stat.uucp (Ray Curci (scri)) Newsgroups: comp.unix.questions,comp.unix.xenix Subject: Re: How to determine file being redirected to in C Keywords: redirection Message-ID: <7419@pyr.gatech.EDU> Date: 28 Feb 89 04:14:21 GMT References: <10@sherpa.UUCP> Sender: news@pyr.gatech.EDU Reply-To: curci@stat.fsu.edu (Ray Curci (scri)) Distribution: na Organization: Dept. of Statistics, Florida State Univ. Lines: 15 In article <10@sherpa.UUCP> rac@sherpa.UUCP (Roger A. Cornelius) writes: >... Anyway, can someone tell me how to determine (in C) >if output is being redirected, or more precisely, how to determine the >file output is being redirected to. >Roger rac@sherpa > uunet!sherpa!rac You may want to investigate the isatty() function call. I believe that you can use something like: isatty(stdout) which will tell you if standard out is going to a terminal (the usual case), or if it has been redirected via a pipe or into a file. ray curci florida state university supercomputer institute curci@stat.fsu.edu, curci@nu.cs.fsu.edu