I have an apache web-server running a python CGI. The idea is that the user enters R code (a statistical language - http://www.r-project.com
), the python CGI writes this to a text file, batches that file using the R executable, and then reads the R output from another file.
Everything runs with no error, however, although the CGI writes the R code to the batching file, when it is batched it's like an empty file! The code that was written to it is ignored.
I'm running the apache server as user www all batching and output files are stored in /home/www
Any ideas? The code follows:
import cgitb; cgitb.enable() # Turn on CGI debugging info
from os import system, getcwd
# HTTP headers
print 'Status: 200 OK'
print 'Content-type: text/html'
# HTML head
print '''<html><head><title>Test R Batch CGI</title></head><body>'''
# Get the form fields, if any
form = cgi.FieldStorage()
if not form.has_key("data"):
# No form data means this is the first access; output the form
print '''<FORM METHOD="POST" action="rexecute">
Type your data here: <input name=data value="" type=text><br>
<input type=submit value="Submit"><br>
RCommands = form.getvalue('data')
RFile = "/home/www/R.r"
f = file(RFile, 'w')
command = "R CMD BATCH /home/www/R.r /home/www/r.rout"
ROutFile = "/home/www/r.rout"
f = file(ROutFile, 'r')
# HTML end