Functions - system

exec
Executes an operating system command as a subprocess of the current process.
 system:Process|system:Error proc = system:exec("ls", {}, "/", "-la")
getEnv
Returns the environment variable value associated with the provided name.
 string port = system:getEnv("HTTP_PORT");
getUserHome
Returns the current user's home directory path.
 string userHome = system:getUserHome();
getUsername
Returns the current user's name.
 string username = system:getUsername();
uuid
Returns a random UUID string.
 string providerId = system:uuid();

exec

(string command, map env, string? dir, string[] args)

returns Process | Error
Executes an operating system command as a subprocess of the current process.
 system:Process|system:Error proc = system:exec("ls", {}, "/", "-la")

Parameters

  • command string
  • The name of the command to be executed

  • env map (default {})
  • Environment variables to be set to the process

  • dir string? (default ())
  • The current working directory to be set to the process

  • args string[]
  • Command arguments to be passed in

  • Return Type

    (Process | Error)
  • A system:Process object if successful or else a system:Error if a failure occurs

getEnv

(string name)

returns string
Returns the environment variable value associated with the provided name.
 string port = system:getEnv("HTTP_PORT");

Parameters

  • name string
  • Name of the environment variable

  • Return Type

    (string)
  • Environment variable value if it exists or else an empty string

getUserHome

()

returns string
Returns the current user's home directory path.
 string userHome = system:getUserHome();
  • Return Type

    (string)
  • Current user's home directory if it can be determined or else an empty string

getUsername

()

returns string
Returns the current user's name.
 string username = system:getUsername();
  • Return Type

    (string)
  • Current user's name if it can be determined or else an empty string

uuid

()

returns string
Returns a random UUID string.
 string providerId = system:uuid();
  • Return Type

    (string)
  • The random string