[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can popen2 be avoided?
From: |
John S. Gwynne |
Subject: |
Re: Can popen2 be avoided? |
Date: |
Wed, 06 Sep 2000 16:58:05 -0400 |
| I have trouble using popen-close (see bug-octave 2000-276) and popen2( see
| help-octave 2000-722).
| For my students, I'm making some simulations, where the calculations are
| done in octave, but the interface is in Tcl/Tk.
|
| The interface (which I start with popen from octave), is perfectly able to
| send strings to octave, but I would like the output of octave to be shown in
| the same interface, not to stdout. Since I can't get popen2 to work, is
| there another way to send the output of octave to the interface? I'm not
| very familiar with communicating between processes (as you might have
| noticed...), so...can someone help me?
|
| Thanks,
| Stef.
FWIW, I had the same problem with popen2. I ended up using a socket
pair for two-way communication with an external application.
The simple interface has four operations: 0: close, 1: open, 2: read,
3: write. The first write specifies the appliction to run.
socketID = socket(1); // create socket
status = socket(3, socketID, appName); // start application appName
status = socket(3, socketID, sendString); // send to stdin of app
[msg status] = socket(2, socketID, timeout, termChar); // receive from
// stdout of app terminated by either a
// timeout of the character termChar.
status = socket(0,socketID); // close socket
It's pretty simple, but it worked for what I was doing (no guarantees
and no security).... an interface between octave and a root
(http://root.cern.ch/root) based gui.
if you want to have a look, try
ftp://jsgpc.mrcday.com/pub/octave/octaveSockets.tar.gz
john gwynne
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------