Check if OS is Solaris

后端 未结 1 1316
Happy的楠姐
Happy的楠姐 2021-01-18 11:29

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

相关标签:
1条回答
  • 2021-01-18 11:56

    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'])
    
    0 讨论(0)
提交回复
热议问题