equiv. of C stderr?? 
Author Message
 equiv. of C stderr??

I've been unable to figure out a way of redirecting console output to a
file while still sending the occasional nugget of information to the
screen..

In C, I would do something like the following:

   printf("output to be routed to file");
   fprintf(stderr, "blessed nugget of info");

The printf output would be redirected, the fprintf output would still
appear on my console.  The only idea I've come up with is actually
specifying the file to output to as a variable or on the command line,
but I'd rather not.  Is there a default unit # for standard error?

- Andrew



Sat, 30 Nov 1996 23:24:54 GMT  
 equiv. of C stderr??

Quote:
>I've been unable to figure out a way of redirecting console output to a
>file while still sending the occasional nugget of information to the
>screen..

That depends on your system (heard that one before? :-)

There is no default unit number for standard error (because, unlike
in C, there is no concept of "standard error") in fortran.

Some Fortran compilers under UNIX use 0, others use 7.

If you use Linux, opening the file /proc/self/fd/2 and writing to it
will do the trick.

Your compiler may have a non - standard extension to associate
a Fortran unit number with a UNIX file descriptor (FSET on HP's,
if I remember correctly... your mileage will probably vary).  Associating
the Fortran unit 0 with file descriptor 2 will also do the trick.

As a desparate last resort, you might try writing to /dev/tty.  This
is _not_ recommended, however, because one day you'll probably want
to invoke your program in batch, or redirect the error messages
to a separate file.
--

The joy of engineering is to find a straight line on a double
logarithmic diagram.



Sun, 01 Dec 1996 00:10:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Accessing stderr with os.popen (or equiv.)

2. to CS: or not to CS: in F-PC assembler

3. STDERR vs $stderr - delegation bug

4. -- HELP -- instVarAt (Class method equiv?)

5. -- HELP -- instVarNames class variable equiv?

6. ABC equiv please

7. Servlet equiv ?

8. ISE equiv to SmallEiffel's DICTIONARY

9. functional Ruby equiv to this perl snippet

10. ruby equiv to python execfile?

11. Newbie: Ruby equiv for Perl while (<>)???

12. eruby (or equiv) for windows?

 

 
Powered by phpBB® Forum Software