Xref: utzoo comp.unix.questions:12013 comp.unix.xenix:5205 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!nic.MR.NET!umn-d-ub!rutgers!bpa!cbmvax!uunet!wucs1!wuphys!wugate!wubios!david From: david@wubios.wustl.edu (David J. Camp) Newsgroups: comp.unix.questions,comp.unix.xenix Subject: Re: How to determine file being redirected to in C Keywords: redirection Message-ID: <325@wubios.wustl.edu> Date: 3 Mar 89 21:24:50 GMT References: <10@sherpa.UUCP> <7419@pyr.gatech.EDU> Reply-To: david@wubios.UUCP (David J. Camp) Distribution: na Organization: Washington University (St. Louis) Lines: 23 In article <7419@pyr.gatech.EDU> curci@stat.fsu.edu (Ray Curci (scri)) writes: :>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 I just received umpteen replies about this. The function call is isatty(fileno(stdout)); -David- -- Bitnet: david@wubios.wustl ^ Mr. David J. Camp Internet: david%wubios@wucs1.wustl.edu < * > Box 8067, Biostatistics uucp: uunet!wucs1!wubios!david v 660 South Euclid Washington University Medical School Saint Louis, MO 63110