A python CGI program can run on linux but not on
windows. By looking at CGIHTTPServer.py, we found out the reason: on windows, the
parent cannot pass os.environ to child demonstrated
as below:
main.py
import os, sys, shutil
env = {}
env["AAA"] = "111"
os.environ.update(env)
print os.environ["AAA"] # ok, updated successful
files = os.popen3(sys.argv[1], "b")
fi, fo, fe = files[0], files[1], files[2]
shutil.copyfileobj(fo, sys.stdout)
errors = fe.read()
fe.close()
if errors: print errors
sts = fo.close()
if sts:
print "exit %#x" % sts
else:
print "exit ok"
test.py
import os, sys
if os.environ.has_key["AAA"]:
print "ok, got AAA"
else:
print "failure"
c:\ test.py
it will print failure
main.py is adopted from CGIHTTPServer.py ?!
ipo_z@cmmail.com
garbage in,garbage out
windows. By looking at CGIHTTPServer.py, we found out the reason: on windows, the
parent cannot pass os.environ to child demonstrated
as below:
main.py
import os, sys, shutil
env = {}
env["AAA"] = "111"
os.environ.update(env)
print os.environ["AAA"] # ok, updated successful
files = os.popen3(sys.argv[1], "b")
fi, fo, fe = files[0], files[1], files[2]
shutil.copyfileobj(fo, sys.stdout)
errors = fe.read()
fe.close()
if errors: print errors
sts = fo.close()
if sts:
print "exit %#x" % sts
else:
print "exit ok"
test.py
import os, sys
if os.environ.has_key["AAA"]:
print "ok, got AAA"
else:
print "failure"
c:\ test.py
it will print failure
main.py is adopted from CGIHTTPServer.py ?!
ipo_z@cmmail.com
garbage in,garbage out