return values of os.system() on win32

rbt rbt at
Fri Jan 13 14:39:42 EST 2006

Paul Watson wrote:
> rbt wrote:
>> Is it safe to say that any value returned by os.system() other than 0 
>> is an error?
>> if os.system('winver') != 0:
>>     print "Winver failed!"
>> else:
>>     print "Winver Worked."
>> Thanks!
> What are you really seeking to do?

This is a corner case. I'm trying to detect if the py script is running 
on a 'special' version of windows. I can't go into the details about 
what makes it unique. Python installs and runs, but the windows API 
isn't as complete as a normal Windows install... among other things, it 
doesn't have a winver.exe file, or if it does, it's crippled... this 
causes os.system('winver') to return a 1... while it returns 0 on 
Windows XP, etc.

> Are you wanting to detect if your 
> code is running on a Windows machine?  Are you wanting to know the 
> version number of Windows?  Why not use popen2() and see the output?

More information about the Python-list mailing list