title: Getting output from the subprocess.Popen command into a webpage? (maybe an apache issue)
body: <p>Here is my program
      import subprocess</p>
  
  <pre><code>print "Content-type:text/html\r\n\r\n"
  print "File starting to execute"
  print "&lt;br&gt;"
  proc = subprocess.Popen(["sudo", "python", "test3.py"], stdout=subprocess.PIPE)
  output = proc.stdout.read()
  print "output is %s" %output
  
  print "&lt;br&gt;"
  print "File Executed Awesomely"
  </code></pre>
  
  <p>So when I run it from the command line it works great, like follows-></p>
  
  <pre><code>[root@localhost html]# python test2.py
  Content-type:text/html
  
  
  File starting to execute
  &lt;br&gt;
  
  output is .
  Sent 1 packets.
  
  &lt;br&gt;
  File Executed Awesomely
  [root@localhost html]# 
  </code></pre>
  
  <p>that is perfect the ". Sent 1 packets." is what I want.  But when I run it from the webpage, the webpage just has</p>
  
  <pre><code>File starting to execute
  output is
  File Executed Awesomely
  </code></pre>
  
  <p>so I originally thought this was because I was doing something wrong grabbing the output but I listened on the port with wireshark (my other program it calls send a packet) and it looks like no packets shows up via the webpage call, but it does when I call it on the command line (the same way).  Looking at my apache error_log-></p>
  
  <pre><code>[Wed Jan 18 18:15:11 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
  [Wed Jan 18 18:15:11 2012] [notice] Digest: generating secret for digest authentication ...
  [Wed Jan 18 18:15:11 2012] [notice] Digest: done
  [Wed Jan 18 18:15:11 2012] [warn] ./mod_dnssd.c: No services found to register
  [Wed Jan 18 18:15:11 2012] [notice] Apache/2.2.17 (Unix) DAV/2 configured -- resuming normal operations
  </code></pre>
  
  <p>any suggestions on how I can fix it so my apache cgi-bin script runs the same way as the command line?</p>
  
  <p>EDIT: looking at the log after a few calls it does this repeatedly</p>
  
  <pre><code>[Wed Jan 18 18:22:37 2012] [error] [client 10.117.153.89] :
  [Wed Jan 18 18:22:37 2012] [error] [client 10.117.153.89] sorry, you must have a tty to run sudo 
  </code></pre>