Modules@robinpath/os
os

@robinpath/os

0.1.2Node.jsPublic

System information: hostname, platform, architecture, CPU, memory, network, and more

OS

System information: hostname, platform, architecture, CPU, memory, network, and more

Package: @robinpath/os | Category: Other | Type: Utility

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the os module when you need to:

  • Get the system hostname -- Use os.hostname to perform this operation
  • Get the OS platform (linux, darwin, win32) -- Use os.platform to perform this operation
  • Get the CPU architecture -- Use os.arch to perform this operation
  • Get CPU information -- Use os.cpus to perform this operation
  • Get the number of CPU cores -- Use os.cpuCount to perform this operation

Quick Reference

FunctionDescriptionReturns
hostnameGet the system hostnameHostname
platformGet the OS platform (linux, darwin, win32)Platform string
archGet the CPU architectureArchitecture (x64, arm64, etc.)
cpusGet CPU informationArray of {model, speed} objects
cpuCountGet the number of CPU coresNumber of CPUs
totalmemGet total system memory in bytesTotal memory in bytes
freememGet free system memory in bytesFree memory in bytes
uptimeGet system uptime in secondsUptime in seconds
homedirGet the user home directoryHome directory path
tmpdirGet the OS temp directoryTemp directory path
userInfoGet current user information{username, homedir, shell}
networkInterfacesGet network interface informationObject of interface arrays
typeGet the OS type (Linux, Darwin, Windows_NT)OS type string
releaseGet the OS release versionOS release string
eolGet the OS end-of-line markerEOL string (\n or \r\n)

Functions

hostname

Get the system hostname

Module: os | Returns: string -- Hostname

os.hostname
ParameterTypeRequiredDescription
(none)NoCall with no arguments

platform

Get the OS platform (linux, darwin, win32)

Module: os | Returns: string -- Platform string

os.platform
ParameterTypeRequiredDescription
(none)NoCall with no arguments

arch

Get the CPU architecture

Module: os | Returns: string -- Architecture (x64, arm64, etc.)

os.arch
ParameterTypeRequiredDescription
(none)NoCall with no arguments

cpus

Get CPU information

Module: os | Returns: array -- Array of {model, speed} objects

os.cpus
ParameterTypeRequiredDescription
(none)NoCall with no arguments

cpuCount

Get the number of CPU cores

Module: os | Returns: number -- Number of CPUs

os.cpuCount
ParameterTypeRequiredDescription
(none)NoCall with no arguments

totalmem

Get total system memory in bytes

Module: os | Returns: number -- Total memory in bytes

os.totalmem
ParameterTypeRequiredDescription
(none)NoCall with no arguments

freemem

Get free system memory in bytes

Module: os | Returns: number -- Free memory in bytes

os.freemem
ParameterTypeRequiredDescription
(none)NoCall with no arguments

uptime

Get system uptime in seconds

Module: os | Returns: number -- Uptime in seconds

os.uptime
ParameterTypeRequiredDescription
(none)NoCall with no arguments

homedir

Get the user home directory

Module: os | Returns: string -- Home directory path

os.homedir
ParameterTypeRequiredDescription
(none)NoCall with no arguments

tmpdir

Get the OS temp directory

Module: os | Returns: string -- Temp directory path

os.tmpdir
ParameterTypeRequiredDescription
(none)NoCall with no arguments

userInfo

Get current user information

Module: os | Returns: object -- {username, homedir, shell}

os.userInfo
ParameterTypeRequiredDescription
(none)NoCall with no arguments

networkInterfaces

Get network interface information

Module: os | Returns: object -- Object of interface arrays

os.networkInterfaces
ParameterTypeRequiredDescription
(none)NoCall with no arguments

type

Get the OS type (Linux, Darwin, Windows_NT)

Module: os | Returns: string -- OS type string

os.type
ParameterTypeRequiredDescription
(none)NoCall with no arguments

release

Get the OS release version

Module: os | Returns: string -- OS release string

os.release
ParameterTypeRequiredDescription
(none)NoCall with no arguments

eol

Get the OS end-of-line marker

Module: os | Returns: string -- EOL string (\n or \r\n)

os.eol
ParameterTypeRequiredDescription
(none)NoCall with no arguments

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(standard errors)Check function parameters and authentication
@desc "Hostname and validate result"
do
  set $result as os.hostname
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. Multi-step OS workflow

Chain multiple os operations together.

@desc "Hostname, platform, and more"
do
  set $r_hostname as os.hostname
  set $r_platform as os.platform
  set $r_arch as os.arch
  print "All operations complete"
enddo

2. Safe hostname with validation

Check results before proceeding.

@desc "Hostname and validate result"
do
  set $result as os.hostname
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.2latest1 months ago
Install
$ robinpath add @robinpath/os

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.2
LicenseMIT
Unpacked Size4.0 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

utilities