Topic: Redirected...
Author: Michiel Salters<Michiel.Salters@cmg.nl>
Date: Mon, 17 Dec 2001 15:53:01 GMT Raw View
In article <3C15A365.17558C78@lmf.ericsson.se>, Attila Feher says...
>
>Hi,
>
>Are there any plans, to provide some portable way to find out "who" is
>at the other end of a standard input/output/error stream(s)? Basically
>I try to avoid the term redirected, because it may not be the one to
>beused here. The point is: if I have a little program, where the input
>is coming from an interactive source, I may want to:
>
>cout << "Gimem number: ";
>cin >> number;
>
>while if the thing is redirected, I may want to just read the number.
I think you might be getting into problems quite fast. What if the program
doing the redirection uses the prompt as a clue to provide input?
In general, you have to coordinate the interface between the C++
program and the script anyway. And in that case, you can portably
provide and use a -quiet flag on the command line.
HTH,
--
Michiel Salters
Consultant Technical Software Engineering
CMG Trade, Transport & Industry
Michiel.Salters@cmg.nl
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: Attila Feher <Attila.Feher@lmf.ericsson.se>
Date: Tue, 11 Dec 2001 16:00:10 GMT Raw View
Hi,
Are there any plans, to provide some portable way to find out "who" is
at the other end of a standard input/output/error stream(s)? Basically
I try to avoid the term redirected, because it may not be the one to
beused here. The point is: if I have a little program, where the input
is coming from an interactive source, I may want to:
cout << "Gimem number: ";
cin >> number;
while if the thing is redirected, I may want to just read the number.
Also, it may be possible that I choose a different way of working, when
the output is redirected, into a sort of batch mode.
However I cannot ask cin, cout, cerr etc. for this information in any
portable way I know of.
I feel that adding this "flag" into the streams may not be that
difficult, even knowing that on some systems it may make no sense.
(Actually on some systems the whole cin/cout makes no sense: where does
the standard output go in a BMW engine computer? :-) So on systems,
where the distinction between interactive/dumb streams makes no sense, a
sensible fixed value can be used by the std library implementer. Or in
worst case a setting can tell if it makes sense to read the value...
Anyways this little thing could help writing portable (UNIX like) tools,
using plain C++. I cannot tell how important it is, but since C++
encapsulates all the things about cout/cin/cerr/clog (not like C showing
the "naked" file-handle) it somehow "feels" belonging there...
Are there any plans?
A
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]