I have a WAMP server 3.1.3 running a HTML main page that takes a 'start' date, 'end' date and 'organization' text inputs. The submit button than passes the info to a following php script:
<?php
$from = strtotime($_POST["fromdate"]);
$to = strtotime($_POST["todate"]);
$org = $_POST["org"];
$python = "C:\Python27\python.exe ";
$pyscript = "C:\wamp64\www\DMARC\Sample_Reports\GetOutlookAttachments.py $from $to $org";
echo $python, $pyscript;
chdir("C:\wamp64\www\DMARC\Sample_Reports");
exec("$python $pyscript");
?>
The script takes the data, converts it to the proper format and passes it to a python 2.7 script. The data the python script receives is used to filter some logs. Once the logs are filtered the python script calls an R-markdown script to produce an HTML report. The Python code that calls the rmarkdown script:
cmd = '"C:/PROGRA~1/R/R-3.5.1/bin/x64/Rscript.exe -e \"Sys.setenv(RSTUDIO_PANDOC=\'C:/Program Files (x86)/Pandoc\'); rmarkdown::render(\'../Filter\ Tool/report.Rmd\')\""'
os.system(cmd)
Before, I used to run the python script from cmd, giving it the arguments it needs and everything worked fine. The filtering done by python was correct, rmarkdown analyzed the logs and produced HTML reports. Now that I try running it from a PHP call I constantly get the following in apache_error.log:
Error in loadNamespace(name): there is no package called 'rmarkdown'
I have made sure that R uses the proper paths for libraries, stated the path in the top of the rmarkdown script. I made sure that what goes into exec() works by pasting it's value into cmd and it runs. Anything else I can try?
EDIT:
As requested here is the top of the markdown script:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r include=FALSE}
library(XML)
library(methods)
library(readbulk)
library(zoo)
library(tidyr)
library(stringr)
library(data.table)
library(ggplot2)
library(plyr)
library(plotly)
library(IPtoCountry)
library(rworldmap)
library(knitr)
library(rmarkdown)
.libPaths(c("C:/Users/username/Documents/R/win-library/3.5", "C:/Program Files/R/R-3.5.1/library"))
```