premature end of script headers

Phil Frost indigo at bitglue.com
Fri Jul 9 23:24:12 EDT 2004


What that error means is that when your webserver ran the program, the
program did not output a correct set of HTTP headers. A good way to test
is usually to try running the program yourself from a shell. If the
problem then isn't obvious, begin trimming your script until it works,
and then the last thing you changed you know is related to the problem.
This is basic troubleshooting.

On Sat, Jul 10, 2004 at 01:11:13PM +1000, Ajay Brar wrote:
> 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"

> -- 
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list