I have the following snippet:
#!/usr/bin/env python
import sys
mypath = "D:\inetpub\wwwroot"
if mypath:
try:
print "Path: %s" % mypath
if mypath.find("/"):
print "OS: Linux/Unix"
elif mypath.find(":"):
print "OS: Windows"
else:
print "OS: Unknown"
except:
print "Error"
else:
print "[?] OS detection failure."
execution output:
$ python test.py
Path: D:\inetpub\wwwroot
OS: Linux/Unix
What am I doing wrong? I'm getting the opposite result as I expect. Or is there a better way to do this? "/" -> Linux/Unix and ":" -> Windows