Python CGI running commands under NT
osuchw at my-deja.com
osuchw at my-deja.com
Mon Apr 17 22:21:15 EDT 2000
In article
<2B1262E83448D211AE4B00A0C9D61B03BA72AC at MSGEURO1>,
Pieter Claerhout <PClaerhout at CREO.BE> wrote:
> I made a Python CGI-script that executes a DOS-
command and
> should return the result in a HTML page. The
script looks
> as follows:
>
> import os
>
> pipe = os.popen("ipconfig", 'r')
> text = pipe.read()
> del pipe
>
> print "Content-type: text/html"
> print
> print "IPConfig on AV2700"
> print "<br>"
>
> print '<pre>'
> print text
> print '</pre>'
>
> If I run this script from the command line, it
works fine, but
> when I open it using Internet Information
Server, all is shown
> except the contents of the variable text. Any
ideas what could
> be wrong? Is it maybe a setting in IIS or are
these options
> not allowed in CGi-scripts?
I used ASP and got results you wanted. Sample
included.
Waldemar Osuch
8<-------------------------------------
<%@ LANGUAGE = Python %>
<%
import win32pipe
from win32api import GetComputerName
pipe = win32pipe.popen("ipconfig", 'r')
txt = pipe.read()
del pipe
prn = Response.Write
%>
<HTML>
<head>
<title>IPconfig Results</title>
</head>
<body>
<h3>IPConfig on <%prn(GetComputerName())%></h3>
<pre><%prn(txt)%></pre>
</body>
</HTML>
8<----------------------------------------
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list