help-octave
[Top][All Lists]
Advanced

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

Re: Invoke an octave session via pipe


From: Qianqian Fang
Subject: Re: Invoke an octave session via pipe
Date: Mon, 11 May 2009 13:05:22 -0400

hi

thank you all for the help. After reading a working example posted at Lazarus's forum (http://forum.lazarus.freepascal.org/index.php?topic=6693.new;topicseen#new), I realized that I made a stupid mistake when appending '\n' to the end of the command; that's why octave did not respond to my commands. After fixing that mistake, the output were printed correctly.

One follow up question, if I send a command and wait for output, is there a way to tell if octave has finished printing (or in a non-busy state) in the process level ? Now I can set a maximum wait period and record whatever printed before time-out, which is probably not reliable.

thanks

Qianqian


On Fri, May 8, 2009 at 4:53 AM, Sergei Steshenko <address@hidden> wrote:



--- On Thu, 5/7/09, Qianqian Fang <address@hidden> wrote:

> From: Qianqian Fang <address@hidden>
> Subject: Re: Invoke an octave session via pipe
> To: "John W. Eaton" <address@hidden>
> Cc: address@hidden
> Date: Thursday, May 7, 2009, 4:16 PM
> thank you John, and also Michael's
> reply for using the -i option.
>
> I tried -i and my initial pipe read returned the
> "octave:1>" prompt,
> however, sending commands via my pascal function still
> failed to give me any more output to read.
>
> I am not sure I understood the the experiment outlined in
> your reply.
> I ran the "octave --interactive < fifo > foo.out "
> command and it simply
> gave an empty foo.out file; I did not have chance to run
> the cat command
> from another term and octave already quit.
>
> In the past, I only got succeed using pipes to run a .m
> file from
> command line and retrieve the printed results, but that was
> a
> single execution; but now what I am trying to achieve is to
> interact
> with an persistent session (sort of like a GUI), I am not
> sure if this
> is indeed possible with pipe operations.
>
> I also found some possible issues on the pascal side, I
> posted it
> on the Lazarus forum and I will let you know if I get any
> useful
> feedback from there.
>
> Qianqian
>
>
> John W. Eaton wrote:
> > On  7-May-2009, Qianqian Fang wrote:
> >
> > | What makes me curious is why my stdout reading did
> not give me the
> > | octave prompt, i.e. "octave:1>"? looks like once
> octave get started,
> > | it will start something else, which I can not access
> its stdout via
> > | octave's stdout.
> >
> > No, I think Octave writes the prompt and most output
> to stdout.
> > Probably you want to use the --interactive option when
> talking to
> > Octave over a pipe.  If you are on a Unixy
> system, try this
> > experiment:
> >
> >   in one terminal window, run
> >
> >     mkdir fifo
> >     octave --interactive < fifo
> > foo.out
> >
> >   and in another, type
> >
> >     cat > fifo
> >     svd (rand (3))
> >     fprintf (stderr, "stderr!\n")
> >
> > and then look at foo.out.  It should contain all
> of Octave's output
> > except the "stderr!" message, which should have been
> printed to the
> > terminal where you started Octave.
> >
> > jwe
> >
> >   
>

I think JWE meant

mkfifo fifo

, not

mkdir fifo.


I.e. a named pipe is needed (and on Windows is created differently).

Then, after the named fifo is created, another application can write
commands into fifo.

Regards,
 Sergei.





reply via email to

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