cmder

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultCMDTimeout 命令执行超时时间默认值
	DefaultCMDTimeout = 3 * time.Second

	ErrCMDTimeout = errors.New("command execution timed out")
)
View Source
var (
	// DefaultShellTimeout Shell 执行默认超时时间
	DefaultShellTimeout = 10 * time.Second

	// BashCmd 主命令绝对路径
	BashCmd = []string{"/bin/bash"}
)

Functions

func CheckBadCmd added in v0.4.0

func CheckBadCmd(s string) bool

CheckBadCmd 检查命令是否包含潜在非法字符

func RunCmd

func RunCmd(cmdArgs []string, timeout ...time.Duration) cmd.Status

RunCmd 运行命令, 返回结果和状态

func RunCmdCombinedOutput added in v0.5.3

func RunCmdCombinedOutput(cmdArgs []string, timeout ...time.Duration) cmd.Status

RunCmdCombinedOutput 运行命令, 合并输出和错误 2>&1

func RunCmdWithContext

func RunCmdWithContext(ctx context.Context, cmdArgs []string) cmd.Status

RunCmdWithContext 运行命令, 返回结果和状态

func RunCmdWithOptions added in v0.5.3

func RunCmdWithOptions(cmdArgs []string, opts cmd.Options, timeout ...time.Duration) cmd.Status

func RunShell added in v0.6.6

func RunShell(sh string, args ...string) (ok bool)

RunShell 运行 Shell 脚本返回是否执行成功

func RunShellTimeout added in v0.6.6

func RunShellTimeout(sh string, timeout time.Duration, args ...string) (ok bool)

RunShellTimeout 运行 Shell 脚本返回是否执行成功

func RunShellTimeoutWithResult added in v0.6.6

func RunShellTimeoutWithResult(sh string, timeout time.Duration, args ...string) (stdout, errout string, ok bool)

RunShellTimeoutWithResult 运行 Shell 脚本并返回标准输出和错误输出, 以及是否执行成功 示例命令: /bin/bash /opt/app/script/echo.sh my-app 示例调用: RunShellTimeoutWithResult("/opt/app/script/echo.sh", 3*time.Second, "my-app")

func RunShellWithResult added in v0.6.6

func RunShellWithResult(sh string, args ...string) (stdout, errout string, ok bool)

RunShellWithResult 运行 Shell 脚本并返回输出结果

Types

This section is empty.

Jump to

Keyboard shortcuts

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