meisterluv 0 Newbie Poster

Hi everyone I was wondering if I could get some help on environment variables. I am executing a cgi file from a C file with execv(). The cgi is able to generate the html template correctly. However I am unable to grab the "REQUEST_METHOD" since it always returns NULL. Can someone point out my error?

import os, cgi, time
import cgitb; cgitb.enable()

#print "Content-type: text/html\n\n"


#main function
def main():
	
	if os.getenv("REQUEST_METHOD") == 'POST':
		if os.environ['QUERY_STRING']:
			form = cgi.FieldStorage()
			if form.has_key('field'):
				rpn = form['field'].value
				os.putenv("QUERY_STRING", rpn);
				print "ALERT"
				print QUERY_STRING	
				stack = rpn.split()
				newStack = []
				newStack = evalRPN3(stack, newStack)	
				if newStack != None:
					printInfix(newStack)
				else:
					printScreen("Improper RPN Format")	
			else:
				printScreen("")
		else:
			form = None
			
	else:
		env = os.getenv("REQUEST_METHOD")
		query = os.getenv("QUERY_STRING")
		print "THIS IS THE ENV " 
		print env
		print "THIS IS QUERY STRING"
		print query

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.