I have the need to check logically if a computer's operating system is Solaris. In other words I need a way to check if the operating system is Solaris, if so return TRUE
, if not return FALSE
. I can easily check if an OS is Windows, Mac, Linux because I have access to these systems what type
(e.g., "unix", "windows") to search for as this info is commonly google-able. Something along the lines of:
.Platform$OS.type == "unix"
.Platform$OS.type == "windows"
works and there are other approaches well documented on SO (e.g., Sys.info()["sysname"] == "Windows"
). In my search of SO and Google I was led to many questions regarding Windows, Mac, Linux but no way to specifically to determine if the OS is Solaris. For instance this link, which leads to other similar questions it duplicates, addresses determining the OS but not a logical check if Solaris.
How to check the OS within R
How can I programmatically determine if a computer's OS is Solaris?
I may need to be more specific about what forms os Solaris I'm interested in (I'm not sure because I know very little about the OS). Of particular interest are the Solaris systems used in CRAN checks:
Digging into the C code that Sys.info
uses, it ends up with a call to sys/utsname.h
, which should be defined for most Unix-like systems (and is indeed part of the standard).
Looking at this website, it seems like Solaris uses SunOS as the utsname
. Here is a copy just in case that link dies:
The utsname macro
We've already seen one macro in use on a Solaris 2 system, utsname.
As a refresher, here is how we called the utsname macro ...
Figure 12-1 Using the utsname macro
...
utsname: sys SunOS
Also, the Wikipedia article on uname
clearly states that the system name for all Solaris systems is SunOS.
So, just for completeness, you could easily grep
for this in a function:
is.solaris<-function()
grepl('SunOS',Sys.info()['sysname'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With