[R] command line fails

Daniel Nordlund djnordlund at gmail.com
Fri Feb 2 22:43:36 CET 2018


On 2/2/2018 4: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.
> 
> Thanks for the help!
> 
> Mike
> 
> Michael Ashton, CFA
> Managing Principal
> 
> Enduring Investments LLC
> W: 973.457.4602
> C: 551.655.8006
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 

Mike,

on Windows, anytime you send a path that contains a space to the command 
line it needs to be enclosed in double quotes.  Try a call like

"C:/Program Files/R/R-3.4.3/bin/Rscript.exe" "P:/Investments/Trading 
Tools/RV Tools/myfile.r"

I don't know how rscript handles the '\' character (i.e. as an escape or 
not) so I changed the '\' to '/' just to be safe.  And note, the program 
pathname and the file being passed need to be quoted separately.


Hope this helps,

Dan

-- 
Daniel Nordlund
Port Townsend, WA  USA



More information about the R-help mailing list