cmd

package
v0.0.0-...-0c45383 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: GPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

cmd

Usage

local cmd = require("cmd")
local res, err = cmd.exec("bash", "-c", "echo hello world")
if err then error(err) end
print(res)

--- or timeout seconds
local res, err = cmd.exec_by_timeout(15, "bash", "-c", "sleep 5; echo hello world")
if err then error(err) end
print(res)

Documentation

Index

Constants

View Source
const (
	//Timeout default execution timeout in seconds
	Timeout = 3 * time.Minute
)

Variables

View Source
var BeforeExec = []func(cmd *exec.Cmd){
	func(cmd *exec.Cmd) {
		cmd.SysProcAttr = &syscall.SysProcAttr{
			Pgid: os.Getpid(),

			Setsid:    true,
			Pdeathsig: syscall.SIGKILL,
		}
	},
}

Functions

func Exec

func Exec(L *lua.LState) int

Exec lua cmd.exec(command, args...) return ({status=0, stdout="", stderr=""}, err)

func ExecByTimeout

func ExecByTimeout(L *lua.LState) int

ExecByTimeout lua cmd.exec_by_timeout(timeout, command, args...) return ({status=0, stdout="", stderr=""}, err)

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func Preload

func Preload(L *lua.LState)

Preload adds cmd to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local cmd = require("cmd")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL