Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-29-2004, 04:23 PM   #1
LQ Newbie
Registered: Feb 2004
Posts: 23

Rep: Reputation: 15
Python CGI - Batching in R

Hey all,

I have an apache web-server running a python CGI. The idea is that the user enters R code (a statistical language -, 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 cgi
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
print '</body></html>'

Last edited by larsenmtl; 09-29-2004 at 04:25 PM.
Old 09-29-2004, 04:24 PM   #2
LQ Newbie
Registered: Feb 2004
Posts: 23

Original Poster
Rep: Reputation: 15
Ahh crap the http for the r language shoule be


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python CGI script can't write files, permission denied The_Nerd Programming 4 03-17-2005 12:19 PM
how to configure apache in Suse 9.1 t run cgi programmes written in python drako123 Linux - Software 0 08-21-2004 07:27 AM
CGI in Python indian Programming 2 08-18-2004 02:32 PM
problem apache2 CGI python MoinMoin (wiki) brasschaat Linux - Software 1 08-11-2004 08:26 AM
bizarre python behavior - simple cgi variables SerfurJ Programming 2 04-14-2004 02:58 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration