0

I'm trying to compose a .zip file in a CGI program and send that as the content response. I'm getting stuck in that whenever I spawn a program that prints to stdout, that somehow doesn't get accepted by Apache. It seems to be something to do with spawning a program that writes to stdout. The snippet below reproduces this problem. I always get the following error form Apache:

malformed header from script. Bad header=hello world  

print ("Content-Type: text/html");  
print ("");  
#print ("hello world");     <-----This works  
os.system("echo hello world");  <-----This doesn't work

It works fine if I just print the string from my CGI script. If I run it with either statement from the command line, there's no difference in behaviour. Is there something special I need to do to get the stdout from a spawned program out as my respone?

1 Answer 1

1

Try sys.stdout.flush() before calling external programs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.