CGI and HTTP Header Location redirects

D

Derek Basch

Hello,

I have been dealing with some strange behavior using CGI, python and an HTTP
Header "Location:" redirect on an Apache 1.3 server.

If I call a CGI script and perform a "Location:" redirect the script seems to
silently run off the tracks immediately after the redirect. For example "0.xml"
and "1.xml" are created when there is no redirect and only "0.xml" is created
when a redirect does occur (see below).

Also, after enabling suEXEC on the apache server the script executes perfectly
with the redirect. Can anyone explain this behavior? I would guess that it is
related to apache user rights but I can't find any reference to such problems
via Google.

Thanks everyone!,
Derek Basch

-------------------------------------------------

#! /usr/bin/python

import sys
import cgitb

class Trainer:

def train(self):
fs = open("/tmp/0.xml", "w")
fs.close()
## print "Location: " + "http://www.yahoo.com" + "\n\n"
sys.stdout.flush()
fs = open("/tmp/1.xml", "w")
fs.close()

def main():
try:
cgitb.enable()
trainer = Trainer()
trainer.train()

except Exception, inst:
cgitb.handler()

if __name__ == '__main__':
main()




__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
 
P

Paul Rubin

Derek Basch said:
Also, after enabling suEXEC on the apache server the script executes
perfectly with the redirect. Can anyone explain this behavior? I
would guess that it is related to apache user rights but I can't
find any reference to such problems via Google.

Apache probably isn't able to run the cgi because of lack of exec
permission or something like that. The best way to diagnose such
probs is by checking the apache error log, if you have access to it.

Best newsgroup for this type of question is
comp.infosystems.www.servers.unix. Lots of apache experts hang out there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top