PDA

View Full Version : How to distinguish nix from windows?



shoaibi
June 5th, 2008, 07:18 PM
I am connected to a remote system using ssh...
how can i tell if that is a windows based system or nix by running some command?
in other words:

Using a terminal, is there a way I can distinguish from the output of the command that whether it's a nix system or windows?

oh and dont tell me its uname, coz uname gives different output on unices and linux.. :P :D

thanks for reading the post..

az
June 5th, 2008, 07:21 PM
I am connected to a remote system using ssh...
how can i tell if that is a windows based system or nix by running some command?
in other words:

Using a terminal, is there a way I can distinguish from the output of the command that whether it's a nix system or windows?

oh and dont tell me its uname, coz uname gives different output on unices and linux.. :P :D

thanks for reading the post..

uname -a

Martin Witte
June 5th, 2008, 08:13 PM
I would go for an approach where you test the result of command 'uname -a', exists on Unix, not on windows , then test for the result of command 'ver' - this exists on Windows, not on Unix

slavik
June 6th, 2008, 03:35 AM
if you can, get to the root of the file system and look at the structure.

rikxik
June 6th, 2008, 07:07 AM
Use echo - same command for both OS and check the output to decide.

On Windows:


C:\>echo %OS%
Windows_NT


On Unix/Linux:


$ echo %OS%
%OS%


HTH

geirha
June 6th, 2008, 01:10 PM
import sys
sys.platform == 'win32'