Invoke an octave session via pipe
Sergei Steshenko
sergstesh at yahoo.com
Fri May 8 03:53:03 CDT 2009
--- On Thu, 5/7/09, Qianqian Fang <fangqq at gmail.com> wrote:
> From: Qianqian Fang <fangqq at gmail.com>
> Subject: Re: Invoke an octave session via pipe
> To: "John W. Eaton" <jwe at octave.org>
> Cc: help-octave at octave.org
> 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.
More information about the Help-octave
mailing list