This question is built over a previous question I asked Determine OS from a single command line operation
I have a tool capable of executing a command on a remote system when I provide the host name. The remote machine can be Windows or Linux. After executing a command, I should be able to determine the OS from the result of the command.
The solution provided earlier was uname which prints "Linux" on linus OS and fails for windows. It works great theoretically but the problem I have is that any failure of command crashes the tool since Windows returns non zero return code in this case.
So to get around this issue I have two options in front of me
- Force windows command line to return 0 as the exit code irrespective of the actual result. (This has to be done as part of the single command I can execute on the windows system)
- Find a command (like echo) which will succeed on both systems (but unlike echo which gives the same result, should help me identify the OS)
I am not sure if the first option is possible, but a solution to either of them would help