I've written an R script that is scheduled to run each day at a certain time - I had everything working in the windows task scheduler without an issue using:
Program/Script: "C:\Program Files\R\R-3.3.3\bin\i386\Rscript.exe"
Add arguments: "C:\Users\NetworkAdmin\Documents\repo\prod\generateReports.R"
However, I wanted to generalize the same script to run multiple similar tasks on different subsets of the dataset - so I added parameters to generateReports.R. Again, testing it from PowerShell everything was working fine, however when I tried to add the inputs to the "Add arguments" box the script would no longer run.
Here are a few of the iterations I've tried:
Add arguments: "C:\[...]\generateReports.R" "input1" "input2"
Add arguments: "C:\[...]\generateReports.R input1 input2"
Add arguments: "'C:\[...]\generateReports.R' 'input1' 'input2'"
Each time I get the same result - the history of the job says that it had run successfully but it clearly has not (I've tried running a dumbed down version that just outputs the inputs to a txt file to ensure the problem isn't in the script itself).
Does anyone know the correct syntax here?
After many more iterations I've found a work around:
By using:
Program/Script: "C:\Program Files\R\R-3.3.3\bin\i386\Rscript.exe"
Add arguments: "C:\[...]\generateReports.R" -args input1 input2
I'm able to add arguments that are passed the the script, unfortunately the first parameter passed is "-args". So I've just incremented all of the parameters such that -args is captured first, then the two inputs:
junk <- args[1]
input1 <- args[2]
input2 <- args[3]