Zexi Li
Zexi Li

Reputation: 452

How node.js get the Linux release version?

How can I get linux release version? For example, when my code run on a CentOS linux, i could get 'CentOS', if Ubuntu get 'Ubuntu'. I have seen the os module node it self, but can not find any api of this.

Upvotes: 1

Views: 709

Answers (1)

Cyril
Cyril

Reputation: 476

It seems that nothing in the OS module exists to identify the linux distribution. You can get it this way:

exec('cat /etc/*release | grep -E ^NAME', function(error, stdout, stderr) {
    //stdout contains NAME="CentOS Linux", NAME=Fedora depending, ...
    //parse the string to get what you want
});

Source: http://www.novell.com/coolsolutions/feature/11251.html

Upvotes: 2

Related Questions