简体   繁体   中英

subprocess.popen making the cgi script stuck

When opening the page with following code the page keeps loading forever..

import cgitb
import subprocess,shlex
cgitb.enable()
print "Content-type:text/html\r\n\r\n"
print 'Hello'
CMD = '/usr/bin/python -u /path/to/file/filename.py -c %s -r'
cmd = CMD % 'somearg'
proc = subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE)
output, status = proc.communicate()
print '<pre>%s</pre>' % output

and works only after i take out the subprocess.Popen() part. Strange thing is this code used to work before and I don't remember making any change recently that may have messed with it. Also the subprocess.Popen() part works perfectly from python shell, so the code is correct. I am stuck in finding what is making the page load forever. I have searched for solutions on web but cant find one. Looking for suggestions to solve this. Thanks

CMD缺少“ \\ n”。

CMD = '/usr/bin/python -u /path/to/file/filename.py -c %s -r\n'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM