help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem calling an external program (Gretl) multiple times.


From: Jaroslav Hajek
Subject: Re: Problem calling an external program (Gretl) multiple times.
Date: Thu, 4 Feb 2010 08:56:09 +0100

On Thu, Feb 4, 2010 at 8:42 AM, Werner <address@hidden> wrote:
> mmm... you may need to clarify that for me a little, I'm not sure on the
> correct use of fflush, am I supposed to be flushing the output stream? I've
> tried the following all to no avail, the first iteration of this code works
> but on the second pass through it fails (doesn't execute the first command
> in gretl):
> -------------------------------------------------------------------------
> [in,out,pid] = popen2("gretlcli","");
> sleep (0.5);
> for i=1:size(GretlCode,1)
> fputs(in,sprintf("%s%s",GretlCode(i,:),"\n"));
> fflush(in);
> end
> GretlOutput = readstream(out);
> ---------------------------------------------------------------------
> ------------------------------------------------------------------------
> [in,out,pid] = popen2("gretlcli","");
> sleep (0.5);
> for i=1:size(GretlCode,1)
> fputs(in,sprintf("%s%s",GretlCode(i,:),"\n"));
> fflush(out);
> end
> GretlOutput = readstream(out);
> ---------------------------------------------------------------------
> ------------------------------------------------------------------------
> [in,out,pid] = popen2("gretlcli","");
> sleep (0.5);
> for i=1:size(GretlCode,1)
> fputs(in,sprintf("%s%s",GretlCode(i,:),"\n"));
> end
> fflush(in);
> GretlOutput = readstream(out);
> ---------------------------------------------------------------------
> ------------------------------------------------------------------------
> [in,out,pid] = popen2("gretlcli","");
> sleep (0.5);
> for i=1:size(GretlCode,1)
> fputs(in,sprintf("%s%s",GretlCode(i,:),"\n"));
> end
> fflush(out);
> GretlOutput = readstream(out);
> ---------------------------------------------------------------------
>

The stream io is buffered, so when you write to the input stream, data
may not reach the external process until you call fflush on the
stream.

If you double checked and things still don't seem to work for you,
please post a complete code, as simple as possible, that causes the
problem.

regards

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]