premature end of script headers

Ajay Brar abra9823 at mail.usyd.edu.au
Sat Jul 10 05:11:13 CEST 2004


hi!

I have looked around for an explanation for this error and there seem to be a wide variety of explanations. I have most of the time found that it's something to do with my windows adding a \r to the end of line.

however this time, i have no clue why this is happening with my script.

could someone please help.

the script is below. The only error i get in the webserver error_log is
[Sat Jul 10 13:05:34 2004] [error] (2)No such file or directory: exec of /usr/hons2004/abrar1/lib/html/hons/um/saveComponentValue.cgi failed
[Sat Jul 10 13:05:34 2004] [error] [client 203.84.82.127] Premature end of script headers: /usr/hons2004/abrar1/lib/html/hons/um/saveComponentValue.cgi

thanks

Ajay Brar

#!/usr/local/python

import cgi
import um_classes
import utilities

import cPickle as pickle

form = cgi.FieldStorage()

filename=""
if form.has_key("filename"):
 filename=form["filename"].value
 f = open(filename, 'rb')
 um = pickle.load(f)
 f.close()
else:
 raise "Filename attribute must be present. Error"
 
#test if context attribute is present, raise error otherwise
context=""
if form.has_key("context"):
 context=form["context"].value
else:
 raise "Context must be present. Error"

#test if component attribute is present, raise error otherwise
component=""
if form.has_key("component"):
 component=form["component"].value
else:
 raise "Component must be present. Error"

contextObj = um.getContext(context)
componentObj = contextObj.getComponent(component)

evtype = form["evtype"].value
source = form["source"].value
value = form["value"].value

componentObj.addEvidence(um_classes.UM_Evidence(evtype, source, value))

#remove old values
contextObj.removeComponent(component)
um.removeContext(context)

#add new back in
contextObj.addComponent(componentObj)
um.addContext(contextObj)

#write the um back to file
f = open(filename, 'wb')
pickle.dump(um, f)
f.close()

print "Context-Type: text/plain\n\n"
print "Location: addComponentValue.cgi?filename=" + filename + "&context="  + context  + "&component=" + component +"\n\n"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040710/08060a7c/attachment.html>


More information about the Python-list mailing list