Open rootkea opened 7 years ago
my_script.R:
my_script.R
#!/usr/bin/env Rscript i <- as.numeric(commandArgs(TRUE)) print(i:10)
index.php
<?php $n = 3; exec("Rscript my_script.R $n", $out); var_dump($out); <?
Output:
array(1) { [0]=> string(27) "[1] 3 4 5 6 7 8 9 10" }
Shell Output:
$ Rscript my_script.R 3 Loading required package: rJava Loading required package: methods [1] 3 4 5 6 7 8 9 10
Now I need to have the database connection and other processing in my_script.R before I print the result. So Modified my_script.R:
#!/usr/bin/env Rscript i <- as.numeric(commandArgs(TRUE)) rootkea <- mongoDbConnect('rootkea') print(i:10)
array(0) { }
Though I get the shell output as expected, RMongo messes something with php. How do I make RMongo not mess up with the value returned in $out argument?
php
RMongo
$out
I can't think of a good way to solve this.
my_script.R
:index.php
Output:
Shell Output:
Now I need to have the database connection and other processing in
my_script.R
before I print the result. So Modifiedmy_script.R
:Output:
Shell Output:
Though I get the shell output as expected, RMongo messes something with
php
. How do I makeRMongo
not mess up with the value returned in$out
argument?