[Tutor] Environment Variables On Windows
John Purser
jmpurser at gmail.com
Sun Dec 26 22:04:42 CET 2004
>script itself...
>I tried to do this:
>
>import os
>import cgitb; cgitb.enable()
>print "Content-type: text/html\n\n"
>print "Hi there, ",os.system("echo %USERNAME%")
>
>But I don't get anything in the browser (500 error - Internal Server
>Error) and when I run the script in IDLE I get:
>
>Hi there, 0
>
>I guess its not the way to print them, but it's the only way I came up with.
>And I got another question:
>In my server program I have "User CGI Environment Variables" list that
>should have pares of Name:Value in it...
>Whats that? (I guess its the same in all server programs).
>
>Thanks!
>
>BTW, I'm running Windows XP and Abyss Web Server on my PC.
>
>
Mark,
What you're seeing there is the exit code of the command "echo
%USERNAME%" and not the value in the variable our the output of the
command.
Try:
print "Hi there, ",os.environ["USERNAME"]
Sorry, haven't done any CGI stuff with any languages. Can't help you there.
John Purser
More information about the Tutor
mailing list