Operating System
Functions to detect Operating system and version.
Table of Contents
os::detect_os()
Identify the OS the function is run on.
Function has no arguments.
Exit codes
- 0: If OS is successfully detected.
- 1: If unable to detect OS.
Output on stdout
- Operating system name (linux, mac or windows).
Example
os::detect_os
#Output
linux
os::detect_linux_distro()
Identify the distribution flavour of linux.
Function has no arguments.
Exit codes
- 0: If Linux distro is successfully detected.
- 1: If unable to detect OS distro.
Output on stdout
- Linux OS distribution name (ubuntu, debian, suse, etc.,).
Example
os::detect_linux_distro
#Output
ubuntu
os::detect_linux_version()
Identify the Linux version.
Function has no arguments.
Exit codes
- 0: If Linux version is successfully detected.
- 1: If unable to detect Linux version.
Output on stdout
- Linux OS version number (18.04, 20.04, etc.,).
Example
os::detect_linux_version
#Output
20.04
os::detect_mac_version()
Identify the MacOS version.
Function has no arguments.
Exit codes
- 0: If MacOS version is successfully detected.
- 1: If unable to detect MacOS version.
Output on stdout
- MacOS version number (10.15.6, etc.,)
Example
os::detect_linux_version
#Output
10.15.7