Is there a way to detect the platform (Window / Linux) in which the website is running by Groovy / Grails?
Detecting the platform (Window or Linux) by Groovy/Grails
21k views Asked by Hoàng Long At
2
There are 2 answers
0
On
Or for short:
if (System.env['OS'].contains('Windows')){ println "it's Windows" }
Since Groovy provides a map access to getAt/putAt methods.
will return the name of the OS, e.g. "Windows XP". So if you want to figure out whether you're running on Windows or not, you could do something like:
Alternatively,
org.apache.commons.lang.SystemUtils(from the Apache commons-lang project) exposes some boolean constants that provide the same information as the code above, e.g.More specific constants such as these are also available