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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: newbie question: redirect stdout? [message #17192] Thu, 23 September 1999 00:00
m218003 is currently offline  m218003
Messages: 56
Registered: August 1999
Member
In article <37E916E5.9A0B264B@ssec.wisc.edu>,
Liam Gumley <Liam.Gumley@ssec.wisc.edu> writes:
> "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.

How about a journal file? That would also be platform independent.
You open a journal file with
IDL> journal,'mylogfile'

Then you run your program and afterwards you close the journal file with
IDL> journal

Cheers,
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 441787 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
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
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 17:12:21 PDT 2025

Total time taken to generate the page: 0.00601 seconds