Re: Detect if stdin is via keyboard or via < file?
- From: Chris Dollin <kers@xxxxxxxxxx>
- Date: Wed, 31 Aug 2005 12:20:51 +0100
srbstar@xxxxxxxxxxxxx wrote:
> Can a program detect if it's stdin is
> coming from keyboard input vs. being
> redirected from a file?
>
> If it's from a file, I want to fputs()
> the text. But if it's from the keyboard,
> I won't (don't want it typed, then
> fputs()'d.
I found the most straightforward tactic in a similar situation
(whether to issue a prompt or not, for an interactive interpreter)
to be a command-line flag. The program no longer needs to be able
to answer the question.
--
Chris "electric hedgehog" Dollin
Almost all predictions about life in 2015 are wrong in some fundamental
respect.
.
- References:
- Detect if stdin is via keyboard or via < file?
- From: srbstar
- Detect if stdin is via keyboard or via < file?
- Prev by Date: Re: Style isn't always religious
- Next by Date: Re: Greater sensitivity to off-topic than in other comp.lang
- Previous by thread: Re: Detect if stdin is via keyboard or via < file?
- Next by thread: How do you read two values returned by a function?
- Index(es):
Relevant Pages
|