Capturing output from SPAWN [message #11565] |
Fri, 17 April 1998 00:00  |
Dan Peduzzi
Messages: 3 Registered: June 1997
|
Junior Member |
|
|
I would like to capture the output from a data-intensive
program invoked via SPAWN, but (here's the catch) I would
also like to have the program echo its output to the screen.
I've tried using something like this:
spawn,my_binary + ' | tee '+tempfile
spawn,'cat '+tempfile,output
But the problem here, I think, is that the pipe buffers
the output to the screen, and I don't see the output
at the same time it's produced by the binary.
Does anybody know of a way to capture the output AND
see it printed, unbuffered, to the screen?
============================================================ ====
Daniel C. Peduzzi
(work) (personal)
MIT Lincoln Laboratory peduzzi@ma.ultranet.com
peduzzi@ll.mit.edu http://www.ultranet.com/~peduzzi
============================================================ ====
|
|
|
Re: Capturing output [message #31282 is a reply to message #11565] |
Mon, 24 June 2002 13:27  |
Dave Greenwood
Messages: 33 Registered: October 2000
|
Member |
|
|
In a previous article, "Ian Dean" <Ian.d.dean@baesystems.com> wrote:
> Hi,
> A long shot, as I'm using IDL 5.4 under OpenVMS 7.1.
>
> Is there a way of running a sub-process (perhaps using SPAWN) and capture
> its output as it happens to a text widget. I am aware I could use the RESULT
> keyword, but that is only available when the SPAWNed process completes.
>
> It may be possible to use a CALL_EXTERNAL using mailboxes to communicate,
> but this seems a bit heavy handed.
I think you're on the right track with mailboxes, but I don't think you
need to go so far as to use CALL_EXTERNAL. You should be able to SPAWN
(/NOWAIT) a subprocess to run a command procedure. The procedure creates
the mailbox, defines a job-wide logical containing the mailbox device
name and then runs the program with output directed to the mailbox. You
can OPENR the mailbox in IDL, read the output and write it to your text
widget.
The following is a slight modification of a procedure to create a mailbox
in DCL which was posted to comp.os.vms some years ago by Claude Barbe.
The modification simply defines the job-wide logical "output_mailbox".
$ SPAWN/NOLOG/NOSYMBOLS/NOLOGICAL_NAMES/PROCESS=DCLMBX_'F$getj pi( "","PID") -
ATTACH/IDENTIFICATION='F$getjpi("","PID")
$ X = F$context("PROCESS",CTX,"PRCNAM","DCLMBX_''F$getjpi("", "PID")'","EQL")
$ define/job output_mailbox _MBA'F$getjpi(F$pid(CTX),"TMBU")':
$ OPEN/READ/WRITE DCLMBX output_mailbox
$ STOP DCLMBX_'F$getjpi("","PID")
In IDL you can open the mailbox like this (the colon is required,
according to my test):
IDL> openr,lun,'output_mailbox:',/get_lun
BTW, does anyone know how to solve the original problem on Mac and/or
Windows?
Hth,
Dave
ps - I have a macro program, also from Claude, which creates a mailbox
which can be used from DCL. It's from pre-alpha days so I don't know if
it'll compile on alpha without mods or not. But it would have the benefit
of using an image activation instead of a process creation. Email me if
you're interested.
--------------
Dave Greenwood Email: Greenwoodde@ORNL.GOV
Oak Ridge National Lab %STD-W-DISCLAIMER, I only speak for myself
|
|
|
Re: Capturing output [message #31283 is a reply to message #11565] |
Mon, 24 June 2002 12:48  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"Ian Dean" <Ian.d.dean@baesystems.com> writes:
> Hi,
> A long shot, as I'm using IDL 5.4 under OpenVMS 7.1.
>
> Is there a way of running a sub-process (perhaps using SPAWN) and capture
> its output as it happens to a text widget. I am aware I could use the RESULT
> keyword, but that is only available when the SPAWNed process completes.
>
> It may be possible to use a CALL_EXTERNAL using mailboxes to communicate,
> but this seems a bit heavy handed.
>
> I can always supply more info if required.
The only way to do this directly appears to be with the UNIT keyword,
which is not available from VMS.
However, as Reimar says, perhaps you can write the data to a file. If
you SPAWN it using NOWAIT, then your IDL process regains control
immediately while the job runs in parallel. Then your IDL process can
periodically check the temporary file for more output and load it into
the widget as needed.
Craig
|
|
|
Re: Capturing output [message #31294 is a reply to message #11565] |
Mon, 24 June 2002 08:54  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Ian Dean wrote:
>
> Hi,
> A long shot, as I'm using IDL 5.4 under OpenVMS 7.1.
>
> Is there a way of running a sub-process (perhaps using SPAWN) and capture
> its output as it happens to a text widget. I am aware I could use the RESULT
> keyword, but that is only available when the SPAWNed process completes.
>
> It may be possible to use a CALL_EXTERNAL using mailboxes to communicate,
> but this seems a bit heavy handed.
>
> I can always supply more info if required.
>
> Regards,
> Ian
Is it possible to write the data to a temporary file and read this by
the text widget?
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|