I'm still not having any luck with this. I tried the following:
* (defparameter *e* (extensions:run-program "/home/rif/Software/R/bin/R"
'("--no-save")
:pty t :wait nil :input t :output :stream
:error :output))
*E*
* (write-line "a<-1:20" (extensions:process-pty *e*))
"a<-1:20"
* (write-line "save.image('/home/rif/Tmp/saved-R-file')" (extensions:process-pty *e*))
"save.image('/home/rif/Tmp/saved-R-file')"
* *e*
#<process 11742 :RUNNING>
*
According to your suggestion, I would expect the file
/home/rif/Tmp/saved-R-file to exist after executing this sequence, but
it does not. In general, I have zero evidence that I'm successfully
communicating with the R process.
Any help is appreciated.
Cheers,
rif
Alexey Dejneka <[EMAIL PROTECTED]> writes:
> rif <[EMAIL PROTECTED]> writes:
>
> > (defparameter *e* (extensions:run-program "/home/rif/Software/R/bin/R"
> > '("--no-save")
> > :pty t :wait nil :input :stream :output
> > :stream :error :output))
> >
> >
> > The process starts OK. I can use the process-output slot to read all
> > the things R normally prints out at startup time.
> >
> > I'd like to be able to make R plot by saying
> >
> > * (write-line "plot(rnorm(3000))" (extensions:process-input *e*))
> > "plot(rnorm(3000))"
> > * (finish-output (extensions:process-input *e*))
> > NIL
> > *
> >
> > but this has no effect. I have one idea that may be related to the
> > problem. If I run R without the --no-save option, it fails
> > immediately. Looking at the internals of R, it appears that it runs
> >
> > R_interactive = isatty(0);
> >
> > and that for the process started from CMUCL, this is returning 0, so
> > it doesn't believe it's in an interactive R process.
>
> Replace :INPUT :STREAM with :INPUT T and write to PROCESS-PTY instead
> of PROCESS-INPUT.
>
> BTW, isn't it more natural to make :INPUT T mean "use current stdio"
> and :INPUT :PTY (or :INPUT :TTY) mean "bind stdio to the terminal"?
>
> --
> Regards,
> Alexey Dejneka
>
> "Alas, the spheres of truth are less transparent than those of
> illusion." -- L.E.J. Brouwer