another working Example: { echo "print( 1)"; cat;} | R --interactive
but do not end with <ctrl>-D, it overrides the "save workspace" question; use q() instead there is an additional echo where i don't know how to avoid them On Thu, Nov 01, 2012 at 09:14:09AM +0100, Jan van der Laan wrote: > > I have a r-script (rook.R) that starts a Rook server. To present users > from having to start R and type in source("rook.R"), I want to create > a bash script and bat file that starts R and sources the script. > However, to keep the Rook server running R should not close after > running the script and stay in interactive mode. This proves more > difficult than expected. > > I tried various combinations of commandline parameters and pipes, but > none of them seem to work: > > $R -f rook.R --interactive > Runs and quits > > $ cat rook.R | R > Fatal error: you must specify '--save', '--no-save' or '--vanilla' > > $cat rook.R | R --no-save > Runs and quits > > $R --no-save < rook.R > Runs and quits > > $R --no-save --interactive < rook.R > Runs and quits > > I would have expected the --interactive parameter to do what I want, > but it doesn't seem to do anything. > > What does work is to create a .Rprofile with sourc("rook.R") in it in > the directory and then start R (just plain R). However I don't find > this a very elegant solution. I could of create the .Rprofile file in > the bash script which is somewhat better, but still not very elegant. > I end up with the following bash script: > > #!/bin/bash > echo "source(\"rook.R\")" > .Rprofile > R > > Another, not very elegant, possible solution which I haven't tried is > to start a while loop at the end of the script with a sleep command in > it. > > Does there exist a better solution? > > Regards, > > Jan > > ______________________________________________ > 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. ______________________________________________ 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.