package
0.0.0-20250120080617-bb7c638c6f78
Repository: https://github.com/chainreactors/mals.git
Documentation: pkg.go.dev

# README

cmd GoDoc

Functions

exec(command, [timeout=10]) - execute command via exec.Start. Will wait while command is executed. Returns table with values

  • status
  • stdout
  • stderr

The default timeout is 10 seconds after which the command will be terminated. The default timeout may be overriden with an optional timeout value (seconds).

Examples

local cmd = require("cmd")
local runtime = require("runtime")

local command = "sleep 1"
if runtime.goos() == "windows" then command = "timeout 1" end

local result, err = cmd.exec(command)
if err then error(err) end
if not(result.status == 0) then error("status") end
local cmd = require("cmd")
local runtime = require("runtime")

local command = "sleep 5"
if runtime.goos() == "windows" then command = "timeout 1" end

local result, err = cmd.exec(command, 1)
if err then error(err) end
if not(result.status == 0) then error("status") end

# Functions

Exec lua cmd.exec(command) return ({status=0, stdout="", stderr=""}, err).
Loader is the module loader function.
Preload adds cmd to the given Lua state's package.preload table.

# Constants

Timeout default execution timeout in seconds.