How Can I Determine the Operating System with Python?

Gerhard Häring gerhard at bigfoot.de
Thu Mar 21 22:55:08 EST 2002


In article <u9l7h5s6jljpd6 at corp.supernews.com>, hdiwan420 at speakeasy.net wrote:
> ingo <ingoogni at home.nl> writes:
>> >>> os.environ['OS']
>>'Windows_NT'
> If you have nmap or queso installed, you can always do:
> % sudo nmap -v -v -v -sS -O localhost
> or 
> % sudo queso localhost

I take it that wasn't meant seriously.

> Ok, so it's not exact, but it's just as good as any other way and both exist
> on Windows and Unix.

The probability of queso or nmap, let alone sudo being installed on Windows is
probably of about the same order of magnitued as that the newsreader I'm
currently using on win32 (slrn) is installed there.

And nmap isn't a standard Unix tool either. On Unix, the only thing you can
depend on is the presence of "uname", which exactly the right tool for the
task. Only I don't know of an "uname" equivalent for Windows or Mac.

Besides, "nmap -O" (I take it queso is just an alias for that), gives this on
my FreeBSD 4.5-STABLE:

...
No exact OS matches for host (If you know what OS is running on it, see
http://www.insecure.org/cgi-bin/nmap-submit.cgi).
...

which I of course did.

Gerhard



More information about the Python-list mailing list