Say I have a web application, with some sort of system execution. I'm going to use Ruby for this example. This app could be portable and installed on either a Windows or Unix server. If the app uses system commands, is there a way to distinguish what platform the server is, then maybe catch in an if
statement?
Theoretically like this:
os_check = `checkos` # System ticks to execute through the shell
# using fake command
if os_check == 'unix'
# Run Unix Commands
`ls -la`
else if os_check == 'dos'
# Run DOS commands
`dir`
else
puts 'OS not detectable'
end
EDIT
I'm not looking for Ruby specifically (removed the tag). That was an example. I was hoping for a shell command that could execute in both environments and be variable based on what the OS is. I actually have to replicate this sort of function in several languages. Sorry for any confusion.