[EMAIL PROTECTED] wrote: > Hello, > > I am trying to write a python cgi that calls a script over ssh, the > problem is the script takes a very long time to execute so Apache > makes the CGI time out and I never see any output. The script is set > to print a progress report to stdout every 3 seconds but I never see > any output until the child process is killed. > > Here's what I have in my python script: > > command = "ssh -l root %s /scripts/xen/xen-create-win-vps1.sh %s" % > (host, domuname) > output = os.popen(command) > for line in output: > print line.strip()
try sys.stdout.flush() after every print. Or try something like this: import sys, time class FlushFile: def __init__(self, fd): self.fd = fd def flush(self): self.fd.flush() def write(self, str): self.fd.write(str) self.fd.flush() oldstdout = sys.stdout sys.stdout = FlushFile(sys.stdout) for i in range(5): print "Hello", time.sleep(0.5) print -- Thomas Güttler, http://www.thomas-guettler.de/ http://www.tbz-pariv.de/ E-Mail: guettli (*) thomas-guettler + de Spam Catcher: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list