On 02/02/2018 7:52 AM, Michael Ashton wrote:
Hi - Think this is quick help. Not sure how to trap what is causing my simple 
script to run fine in R, but fail immediately when called from rscript. I can 
put all sorts of traps in the script itself, but when called from the command 
line the r window simply flashes and closes.

There's probably a way to find out why rscript is failing, but I don't know it and can't 
seem to find it online. To be clear, I'm not really trying to save the OUTPUT of the 
file...it never even executes as far as I can tell. I'm calling it with C:\Program 
Files\R\R-3.4.3\bin\Rscript.exe "P:\Investments\Trading Tools\RV 
Tools\myfile.r" And again, it executes perfectly if I open the GUI first and then 
run it within R.


I'd try using forward slashes in the path, i.e. "P:/Investments/Trading Tools/RV Tools/myfile.r" I don't remember if R processes the path to the script or whether it's done entirely by the shell, but they shouldn't hurt.

Spaces in file paths sometimes cause trouble. If you put the script in a path with no spaces does that help? If so, you can probably escape that space, but I can't remember what the escape sequence is. (Escapes in Windows can be processed by the command shell or Rscript.exe or both, so it's hard to get them right.) Another alternative might be to change directory to that path and then use a relative path for the R script.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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