🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #5795

Re: Sensing STDOUT redirection in C

#5795
From: Doug Dougherty
Date: Tue, 16 Apr 1991 14:58
18 lines
1165 bytes
collinsa@p4.cs.man.ac.uk (Adrian Collins) writes:

>I am currently writing a program for the PC using C.  I need to be able
>to sense whether STDOUT has been redirected on the command line.  In the
>case where the output has not been redirected the program opens a text
>window and displays the info in that window, but if output redirection
>was used I want the program to output to STDOUT as it should assume that
>the output is to be sent to a file.

>Does anybody know how to sense whether output redirection has been used
>on the command line?

isatty(1)

(Works in Turbo C)
--

	(Another fine mess brought to you by valley@gsbsun.uchicago.edu)
Technical Details
Message-ID: <1991Apr16.145847.20316@midway.uchicago.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!linac!midway!gsbsun!valley
References: <collinsa.671721083@p4.cs.man.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!linac!midway!gsbsun!valley
From: valley@gsbsun.uchicago.edu (Doug Dougherty)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Sensing STDOUT redirection in C
Keywords: STDOUT, Redirection, MSDOS
Message-ID: <1991Apr16.145847.20316@midway.uchicago.edu>
Date: 16 Apr 91 14:58:47 GMT
References: <collinsa.671721083@p4.cs.man.ac.uk>
Sender: news@midway.uchicago.edu (NewsMistress)
Organization: University of Chicago
Lines: 18