Parent

Class/Module Index [+]

Quicksearch

Sys::Uname

The Uname class encapsulates information about the system.


The Uname class encapsulates uname (platform) information.

Public Class Methods

architecture() click to toggle source

The basic instruction set architecture of the current system, e.g. sparc, i386, etc.

# File lib/unix/sys/uname.rb, line 259
def self.architecture
  uname.architecture
end
dhcp_cache() click to toggle source

The string consisting of the ASCII hexidecimal encoding of the name of the interface configured by boot(1M) followed by the DHCPACK reply from the server.

# File lib/unix/sys/uname.rb, line 273
def self.dhcp_cache
  uname.dhcp_cache
end
hw_provider() click to toggle source

The name of the of the hardware provider.

# File lib/unix/sys/uname.rb, line 293
def self.hw_provider
  uname.hw_provider
end
hw_serial() click to toggle source

The ASCII representation of the hardware-specific serial number of the physical machine on which the function is executed.

# File lib/unix/sys/uname.rb, line 287
def self.hw_serial
  uname.hw_serial.to_i
end
isa_list() click to toggle source

The variant instruction set architectures executable on the current system.

# File lib/unix/sys/uname.rb, line 280
def self.isa_list
  uname.isa_list
end
machine() click to toggle source

Returns the machine hardware type.

Example:

Uname.machine # => 'i686'
# File lib/unix/sys/uname.rb, line 239
def self.machine
  uname.machine
end
model() click to toggle source

Returns the model type.

Example:

Uname.model # => 'MacBookPro5,3'
# File lib/unix/sys/uname.rb, line 250
def self.model
  uname.model
end
nodename() click to toggle source

Returns the name of this node within the communications network to which this node is attached, if any. This is often, but not necessarily, the same as the host name.

Example:

Uname.nodename # => 'your_host.foo.com'
# File lib/unix/sys/uname.rb, line 209
def self.nodename
  uname.nodename
end
platform() click to toggle source

The specific model of the hardware platform, e.g Sun-Blade-1500, etc.

# File lib/unix/sys/uname.rb, line 265
def self.platform
  uname.platform
end
release() click to toggle source

Returns the current release level of your operating system.

Example:

Uname.release # => '2.2.16-3'
# File lib/unix/sys/uname.rb, line 219
def self.release
  uname.release
end
srpc_domain() click to toggle source

The Secure Remote Procedure Call domain name.

# File lib/unix/sys/uname.rb, line 299
def self.srpc_domain
  uname.srpc_domain
end
sysname() click to toggle source

Returns the name of this implementation of the operating system.

Example:

Uname.sysname # => 'SunOS'
# File lib/unix/sys/uname.rb, line 197
def self.sysname
  uname.sysname
end
uname() click to toggle source

Returns a struct that contains the sysname, nodename, machine, version and release of your system.

On OS X it will also include the model.

On Solaris, it will also include the architecture and platform.

On HP-UX, it will also include the id_number.

Example:

require 'sys/uname'

p Sys::Uname.uname
# File lib/unix/sys/uname.rb, line 136
def self.uname
  utsname = UnameFFIStruct.new

  if uname_c(utsname) < 0
    raise Error, "uname() function call failed"
  end

  struct = UnameStruct.new
  struct[:sysname]  = utsname[:sysname].to_s
  struct[:nodename] = utsname[:nodename].to_s
  struct[:release]  = utsname[:release].to_s
  struct[:version]  = utsname[:version].to_s
  struct[:machine]  = utsname[:machine].to_s

  if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/
    struct[:model] = get_model()
  end

  if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/
    struct[:architecture] = get_si(SI_ARCHITECTURE)
    struct[:platform]     = get_si(SI_PLATFORM)
    struct[:hw_serial]    = get_si(SI_HW_SERIAL)
    struct[:hw_provider]  = get_si(SI_HW_PROVIDER)
    struct[:srpc_domain]  = get_si(SI_SRPC_DOMAIN)
    struct[:isa_list]     = get_si(SI_ISALIST)
    struct[:dhcp_cache]   = get_si(SI_DHCP_CACHE)

    # FFI and Solaris don't get along so well, so we try again
    struct[:sysname]  = get_si(SI_SYSNAME) if struct.sysname.empty?
    struct[:nodename] = get_si(SI_HOSTNAME) if struct.nodename.empty?
    struct[:release]  = get_si(SI_RELEASE) if struct.release.empty?
    struct[:version]  = get_si(SI_VERSION) if struct.version.empty?
    struct[:machine]  = get_si(SI_MACHINE) if struct.machine.empty?
  end

  if RbConfig::CONFIG['host_os'] =~ /hpux/
    struct[:id_number] = utsname[:__id_number].to_s
  end

  if RbConfig::CONFIG['host_os'] =~ /linux/
    struct[:domainname] = utsname[:domainname].to_s
  end

  # Let's add a members method that works for testing and compatibility
  if struct.members.nil?
    struct.instance_eval(%{
      def members
        @table.keys.map{ |k| k.to_s }
      end
    })
  end

  struct.freeze
end
version() click to toggle source

Returns the current version level of your operating system.

Example:

Uname.version # => '5.9'
# File lib/unix/sys/uname.rb, line 229
def self.version
  uname.version
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.