I am writing a web application that will execute a command on the local Windows server and need to display the output. The Popen() call in my code executes fine on the Python interpreter but gives a nasty error when executed via IIS. Thanks!!!!
Error text:
Traceback (most recent call last):
File "C:\pythonapps\mystdout.py", line 9, in print Popen('ipconfig', shell=True, stdout=PIPE).communicate()[0]
File "C:\Python27\lib\subprocess.py", line 672, in init errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File "C:\Python27\lib\subprocess.py", line 774, in _get_handles p2cread = _subprocess.GetStdHandle(_subprocess.STD_INPUT_HANDLE)
WindowsError: [Error 6] The handle is invalid
from subprocess import *
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>FSPCT app</title>"
print "</head>"
print "<body>"
print Popen('ipconfig', shell=True, stdout=PIPE).communicate()[0]
print "</body>"
print "</html>"