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

Home » Public Forums » archive » Capturing output from SPAWN
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
Capturing output from SPAWN [message #11565] Fri, 17 April 1998 00:00 Go to next message
Dan Peduzzi is currently offline  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 Go to previous message
Dave Greenwood is currently offline  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 Go to previous message
Craig Markwardt is currently offline  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 Go to previous message
R.Bauer is currently offline  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
============================================================ =======
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: "Program Code area full" error message
Next Topic: Re: axis is too thin? - test.ps (0/1)

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

Current Time: Wed Oct 08 13:43:17 PDT 2025

Total time taken to generate the page: 0.00632 seconds