comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: newbie question: redirect stdout?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: newbie question: redirect stdout? [message #17196 is a reply to message #17192] Wed, 22 September 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
"Andreas V. Kadavanich" wrote:
> I'm running IDL 5.2.1 on a PowerMac
>
> I am running a batch program which takes about 5 hours per iteration (so I
> don't want to sit there watching) and generates a lot of output (mostly
> diagnostic messages) to stdout.
>
> I would like to log this output to a file, preferably by redirecting
> stdout (and stderr) to a file. I am stumped as to how to accomplish this
> within IDL short of changing all my print statements to explicitly write
> to a file (which wouldn't help with IDL generated messages).

On UNIX systems, you can use standard input and output, e.g.

% idl < input > output

but since you're on a Mac, this doesn't help.

One approach is to change your PRINT statements to PRINTF, and use the
standard output logical unit number (-1) when you want output to the log
window (IDL reserves the logical unit numbers 0, -1, -2 for stdin,
stdout, stderr). Here's an example:

PRO MYPRO, OUTFILE=OUTFILE

;- Check output file keyword

if n_elements(outfile) eq 0 then begin
;- No output file specified, so send output to stdout
outlun = -1
endif else begin
;- Output file was specified, so open it
openw, outlun, outfile, /get_lun
endelse

;- Print startup message
printf, outlun, 'Program started at ', systime(1)

;*** Use PRINTF instead of PRINT in your program ***

;- Print finish message
printf, outlun, 'Program finished at ', systime(1)

;- Close the output file if necessary
if outlun gt 0 then free_lun, outlun

END

For more information, consult the online help:
IDL> ? logical unit numbers

It is true that this won't re-direct any error messages from IDL to the
output file. But messages from IDL are most likely to be either
compilation messages or fatal error messages, and you'll see these in
the command log window easily because all other output is going to a
file. If you want to get really tricky, you can trap the IDL errors
yourself. See David Fanning's tip at
http://www.dfanning.com/tips/catch_trace.html

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Help with moving from 8 to 24 bit colour
Next Topic: Re: Inexpensive / free-ware similar to IDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 13:15:57 PDT 2025

Total time taken to generate the page: 1.03714 seconds