Re: Capturing screen output [message #28086] |
Tue, 20 November 2001 14:21  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
David Shadovitz wrote:
>
> I'm running IDL 5.4 on a Sun.
>
> I've got a file, cpsub1, which looks like this:
>
> $ cat cpsub1
> echo "computePPP, /batch, inputfile='abc.hdf'" | idl
>
> If I run it by simply typing cpsub1 at the command line, all of the IDL
> messages and PRINT statement outputs are sent to the screen:
>
> $ cpsub1
> % Compiled module: MODULE1
> % Compiled module: MODULE2
> % Compiled module: MODULE3
> Entered main routine...
> Computing the power...
> Done.
> $
>
> I'd like to capture that information in a log file, so I tried
> redirecting standard output, like this:
>
> $ cat cpsub2
> echo "computePPP, /batch, inputfile='abc.hdf'" | idl > cplog2
>
> $ cpsub2
> % Compiled module: MODULE1
> % Compiled module: MODULE2
> % Compiled module: MODULE3
> $
>
> As you can see, now only the IDL messages are written to the screen.
> But the PRINT statement outputs aren't sent to the log file! Upon
> completion, cplog2 is a 0-byte file.
>
> Then I tried redirecting both standard output and standard error:
>
> $ cat cpsub3
> echo "computePPP, /batch, inputfile='abc.hdf'" | idl > cplog3 2>&1
> $ cpsub3
> $
>
> Now nothing is written to the screen. But neither is it going to the
> log file! Upon completion, cplog3 is a 0-byte file.
>
> Can anyone help me capture the IDL messages and the PRINT statement
> output into a file? I'm running my code in this odd manner because
> ultimately I want to run the job in batch mode via 'ssub'.
David,
The following method works for me (I normally use the C shell):
#---cut here---
#!/bin/csh -f
# Sample script to execute IDL in batch mode
# Create IDL run script
echo "print, 'Hello world'" > runidl
echo "exit" >> runidl
# Run IDL
/usr/local/bin/idl runidl >& runidl.out
#---cut here---
You may need to adjust the last line if IDL is installed in a
non-default directory.
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
Re: Capturing screen output [message #28121 is a reply to message #28086] |
Mon, 26 November 2001 09:54   |
David Shadovitz
Messages: 19 Registered: September 2000
|
Junior Member |
|
|
Liam,
Thanks for that. But I cannot even get that far! If I just make a simple
file containing IDL commands, it runs fine unless I try to redirect its
output. When I redirect its output, the output file is empty. Here's what I
mean:
$ cat runidl
print, 'Hello world'
exit
$ idl runidl
IDL Version 5.4 (sunos sparc). (c) 2000, Research Systems, Inc.
Hello world
$ idl runidl > runidl.out
IDL Version 5.4 (sunos sparc). (c) 2000, Research Systems, Inc.
$ cat runidl.out
$
Any ideas?
-David
"Liam E. Gumley" wrote:
> David Shadovitz wrote:
>>
>> I'm running IDL 5.4 on a Sun.
>>
>> I've got a file, cpsub1, which looks like this:
>>
>> $ cat cpsub1
>> echo "computePPP, /batch, inputfile='abc.hdf'" | idl
>>
>> If I run it by simply typing cpsub1 at the command line, all of the IDL
>> messages and PRINT statement outputs are sent to the screen:
>>
>> $ cpsub1
>> % Compiled module: MODULE1
>> % Compiled module: MODULE2
>> % Compiled module: MODULE3
>> Entered main routine...
>> Computing the power...
>> Done.
>> $
>>
>> I'd like to capture that information in a log file, so I tried
>> redirecting standard output, like this:
>>
>> $ cat cpsub2
>> echo "computePPP, /batch, inputfile='abc.hdf'" | idl > cplog2
>>
>> $ cpsub2
>> % Compiled module: MODULE1
>> % Compiled module: MODULE2
>> % Compiled module: MODULE3
>> $
>>
>> As you can see, now only the IDL messages are written to the screen.
>> But the PRINT statement outputs aren't sent to the log file! Upon
>> completion, cplog2 is a 0-byte file.
>>
>> Then I tried redirecting both standard output and standard error:
>>
>> $ cat cpsub3
>> echo "computePPP, /batch, inputfile='abc.hdf'" | idl > cplog3 2>&1
>> $ cpsub3
>> $
>>
>> Now nothing is written to the screen. But neither is it going to the
>> log file! Upon completion, cplog3 is a 0-byte file.
>>
>> Can anyone help me capture the IDL messages and the PRINT statement
>> output into a file? I'm running my code in this odd manner because
>> ultimately I want to run the job in batch mode via 'ssub'.
>
> David,
>
> The following method works for me (I normally use the C shell):
>
> #---cut here---
> #!/bin/csh -f
>
> # Sample script to execute IDL in batch mode
>
> # Create IDL run script
> echo "print, 'Hello world'" > runidl
> echo "exit" >> runidl
>
> # Run IDL
> /usr/local/bin/idl runidl >& runidl.out
> #---cut here---
>
> You may need to adjust the last line if IDL is installed in a
> non-default directory.
>
> Cheers,
> Liam.
> Practical IDL Programming
> http://www.gumley.com/
|
|
|
Re: Capturing screen output [message #28218 is a reply to message #28121] |
Mon, 26 November 2001 10:49  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
David Shadovitz wrote:
>
> Liam,
>
> Thanks for that. But I cannot even get that far! If I just make a simple
> file containing IDL commands, it runs fine unless I try to redirect its
> output. When I redirect its output, the output file is empty. Here's what I
> mean:
>
> $ cat runidl
> print, 'Hello world'
> exit
>
> $ idl runidl
> IDL Version 5.4 (sunos sparc). (c) 2000, Research Systems, Inc.
> Hello world
>
> $ idl runidl > runidl.out
> IDL Version 5.4 (sunos sparc). (c) 2000, Research Systems, Inc.
>
> $ cat runidl.out
> $
>
> Any ideas?
David,
Your example works fine for me in Solaris 7 with IDL 5.3:
$ cat runidl
print, 'Hello world'
exit
$ idl runidl
IDL Version 5.3 (sunos sparc). (c) 1999, Research Systems, Inc.
Hello world
$ idl runidl > runidl.out
IDL Version 5.3 (sunos sparc). (c) 1999, Research Systems, Inc.
$ cat runidl.out
Hello world
This might be a platform specific bug in IDL 5.4 on Solaris. You might
want to check with RSI tech support.
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
Re: Capturing screen output [message #28219 is a reply to message #28121] |
Mon, 26 November 2001 10:40  |
Ken Mankoff
Messages: 158 Registered: February 2000
|
Senior Member |
|
|
Hi David, Liam
Liam: Are you using IDL 5.4?
I noticed this change when I switched to v5.4, both on a Linux and Sun
system. I wonder if RSI changed stderr/stdout or something like that. All
my atjobs stopped sending me output. I ran the commands interactively and
all appeared normal. However, I cannot get the redirect command to work in
v5.4. Makes debugging harder...
Not even a 'printf, -2, "Hello World"' works!
David, my solution was this: If the output is *not* critical, then debug
by starting IDL and typing:
IDL> @filename
where 'filename' will be used like this:
% idl < filename >& output.txt
If output is important for more than debugging, I do the following:
IDL> mail, 'me@some.com you@dot.com', 'me', 'a message', important_output
PRO mail, to, from, subj, mesg
unique = STRTRIM( STRING( LONG( systime( 1 ) ) ), 2 ) + '.email'
openw, lun, unique, /get
printf, lun, "To: " + to ; To, From, Subject necessary for sendmail
printf, lun, "From: " + from
printf, lun, "Subject: " + subj
printf, lun, mesg
close, lun
sendCmd = 'sendmail -t < ' + unique
spawn, sendCmd, /sh
cleanCmd = 'rm ' + unique
spawn, cleanCmd, /sh
END
hope this helps, and please let us know if you get non-interactive output
captured!
-k.
On Mon, 26 Nov 2001, David Shadovitz wrote:
> Liam,
>
> Thanks for that. But I cannot even get that far! If I just make a simple
> file containing IDL commands, it runs fine unless I try to redirect its
> output. When I redirect its output, the output file is empty. Here's what I
> mean:
>
> $ cat runidl
> print, 'Hello world'
> exit
>
> $ idl runidl
> IDL Version 5.4 (sunos sparc). (c) 2000, Research Systems, Inc.
> Hello world
>
> $ idl runidl > runidl.out
> IDL Version 5.4 (sunos sparc). (c) 2000, Research Systems, Inc.
>
> $ cat runidl.out
> $
>
> Any ideas?
> -David
>
> "Liam E. Gumley" wrote:
>
>> David Shadovitz wrote:
>>>
>>> I'm running IDL 5.4 on a Sun.
>>>
>>> I've got a file, cpsub1, which looks like this:
>>>
>>> $ cat cpsub1
>>> echo "computePPP, /batch, inputfile='abc.hdf'" | idl
>>>
>>> If I run it by simply typing cpsub1 at the command line, all of the IDL
>>> messages and PRINT statement outputs are sent to the screen:
>>>
>>> $ cpsub1
>>> % Compiled module: MODULE1
>>> % Compiled module: MODULE2
>>> % Compiled module: MODULE3
>>> Entered main routine...
>>> Computing the power...
>>> Done.
>>> $
>>>
>>> I'd like to capture that information in a log file, so I tried
>>> redirecting standard output, like this:
>>>
>>> $ cat cpsub2
>>> echo "computePPP, /batch, inputfile='abc.hdf'" | idl > cplog2
>>>
>>> $ cpsub2
>>> % Compiled module: MODULE1
>>> % Compiled module: MODULE2
>>> % Compiled module: MODULE3
>>> $
>>>
>>> As you can see, now only the IDL messages are written to the screen.
>>> But the PRINT statement outputs aren't sent to the log file! Upon
>>> completion, cplog2 is a 0-byte file.
>>>
>>> Then I tried redirecting both standard output and standard error:
>>>
>>> $ cat cpsub3
>>> echo "computePPP, /batch, inputfile='abc.hdf'" | idl > cplog3 2>&1
>>> $ cpsub3
>>> $
>>>
>>> Now nothing is written to the screen. But neither is it going to the
>>> log file! Upon completion, cplog3 is a 0-byte file.
>>>
>>> Can anyone help me capture the IDL messages and the PRINT statement
>>> output into a file? I'm running my code in this odd manner because
>>> ultimately I want to run the job in batch mode via 'ssub'.
>>
>> David,
>>
>> The following method works for me (I normally use the C shell):
>>
>> #---cut here---
>> #!/bin/csh -f
>>
>> # Sample script to execute IDL in batch mode
>>
>> # Create IDL run script
>> echo "print, 'Hello world'" > runidl
>> echo "exit" >> runidl
>>
>> # Run IDL
>> /usr/local/bin/idl runidl >& runidl.out
>> #---cut here---
>>
>> You may need to adjust the last line if IDL is installed in a
>> non-default directory.
>>
>> Cheers,
>> Liam.
>> Practical IDL Programming
>> http://www.gumley.com/
>
>
>
--
Ken Mankoff
LASP://303.492.3264
http://lasp.colorado.edu/~mankoff/
|
|
|