Documentation
¶
Index ¶
- func ApplyEnv(cmd *exec.Cmd, env ...string)
- func Exec(ctx context.Context, shell string) (string, error)
- func ExecWithLog(ctx context.Context, shell string, logFile string) error
- func ExecWithLogAppend(ctx context.Context, shell string, logFile string) error
- func ExecWithOutput(ctx context.Context, shell string) error
- func ExecWithPipe(ctx context.Context, shell string) (io.ReadCloser, error)
- func ExecWithStdinProgress(ctx context.Context, name string, args, env []string, stdin io.Reader, ...) (string, error)
- func Execf(ctx context.Context, format string, args ...any) (string, error)
- func ExecfAsync(ctx context.Context, format string, args ...any) error
- func ExecfWithDir(ctx context.Context, dir, format string, args ...any) (string, error)
- func ExecfWithEnv(ctx context.Context, env []string, format string, args ...any) (string, error)
- func ExecfWithOutput(ctx context.Context, format string, args ...any) error
- func ExecfWithPipe(ctx context.Context, format string, args ...any) (io.ReadCloser, error)
- func ExecfWithTimeout(ctx context.Context, timeout time.Duration, format string, args ...any) (string, error)
- func IsPTYError(err error) error
- type MessagePing
- type MessageResize
- type Turn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecWithLog ¶
ExecWithLog 执行 shell 命令并将输出覆盖写入指定的日志文件
func ExecWithLogAppend ¶ added in v3.3.6
ExecWithLogAppend 执行 shell 命令并将输出追加到指定的日志文件
func ExecWithOutput ¶ added in v3.3.6
ExecWithOutput 执行已拼好的 shell 命令并输出到终端
func ExecWithPipe ¶ added in v3.3.6
ExecWithPipe 执行已拼好的 shell 命令并返回管道
func ExecWithStdinProgress ¶ added in v3.3.1
func ExecWithStdinProgress( ctx context.Context, name string, args, env []string, stdin io.Reader, total int64, interval time.Duration, progress func(written, total int64, rate float64), ) (string, error)
ExecWithStdinProgress 以外部命令消费 stdin,同时按周期通过 progress 回调输出进度
func ExecfAsync ¶
ExecfAsync 异步执行 shell 命令 异步即命令要活过调用方,入口断开取消链,否则 sleep 1 && systemctl restart acepanel 这类自杀式操作 会在 HTTP 响应写完的瞬间被杀且无人察觉
func ExecfWithDir ¶
ExecfWithDir 在指定目录下执行 shell 命令
func ExecfWithEnv ¶ added in v3.3.2
ExecfWithEnv 安全执行 shell 命令,环境变量仅注入子进程
func ExecfWithOutput ¶
ExecfWithOutput 按格式串拼出 shell 命令后执行并输出到终端
func ExecfWithPipe ¶
ExecfWithPipe 按格式串拼出 shell 命令后执行并返回管道
func ExecfWithTimeout ¶
func ExecfWithTimeout(ctx context.Context, timeout time.Duration, format string, args ...any) (string, error)
ExecfWithTimeout 执行 shell 命令并设置超时时间,ctx 取消或超时到期均终止进程
func IsPTYError ¶
IsPTYError Linux kernel return EIO when attempting to read from a master pseudo terminal which no longer has an open slave. So ignore error here. See https://github.com/creack/pty/issues/21
Types ¶
type MessageResize ¶
type MessageResize struct {
Resize bool `json:"resize"`
Columns uint `json:"columns"`
Rows uint `json:"rows"`
}
MessageResize 终端大小调整消息