Dear all,

I am trying to wrap a *nix shell script around R for a particular  
purpose, for which I need to get R to execute predetermined commands  
but retain interactivity and allow user input during their execution.  
A straight redirection of standard input is therefore not appropriate,  
and I don't think "littler" is the solution because I don't want to  
write an independent R script.

What I want is effectively something like what ruby does with the '-e'  
option:

$ ruby -e 'gets'
<waits for input from terminal>

R seems to accept an '-e' option too, even though I can't see it  
mentioned in the output from 'R -h', but it doesn't work the same:

$ R --slave --vanilla -e 'scan(what=character(0),nlines=1,quiet=T)'
character(0)
$

The only way I can get this to work is by creating an .Rprofile file  
containing the commands I want to run, but this is suboptimal for a  
number of reasons: I have difficulties if an .Rprofile already exists  
in the working directory, the default packages are not loaded, and the  
process doesn't quit if stop() is called.

I have a vague inkling that this may be achievable with a  
pseudoterminal (pty) or named pipe, but if anyone knows a simpler  
route I'd be glad to avoid getting involved in that kind of thing...

Many thanks in advance.
Jon

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to