How to determine file being redirected to in C
David J. Camp
david at wubios.wustl.edu
Sat Mar 4 07:24:50 AEST 1989
In article <7419 at pyr.gatech.EDU> curci at stat.fsu.edu (Ray Curci (scri)) writes:
:>In article <10 at sherpa.UUCP> rac at 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 at 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 at wubios.wustl ^ Mr. David J. Camp
Internet: david%wubios at wucs1.wustl.edu < * > Box 8067, Biostatistics
uucp: uunet!wucs1!wubios!david v 660 South Euclid
Washington University Medical School Saint Louis, MO 63110
More information about the Comp.unix.questions
mailing list