Getting OS Version

Is there any function to get the type and version of the OS?

+3
source share
2 answers

I do not know about * nix, I'm afraid, but you can just use io popen to get the result, for example, for example, on Windows, the following returns standard information about the version of Windows

local f = io.popen("ver") -- runs command
local l = f:read("*a") -- read output of command
print(l)
f:close()
+3
source

uname, of course, gives the kernel version, but if you want to find out the version of the distribution, you can use lsb_release -ait if it is available (note the comment by Roman Cheplyaka).

local f = io.popen("lsb_release -a")
local s = f:read("*a")
f:close()
--# Do something with s...

The stream is the same as in the Windows version.

+2
source

Source: https://habr.com/ru/post/1763470/


All Articles