Documentation
¶
Index ¶
- func Exec(shell string) (string, error)
- func ExecWithLog(ctx context.Context, shell string, logFile string) error
- func ExecWithStdinProgress(ctx context.Context, name string, args []string, stdin io.Reader, total int64, ...) (string, error)
- func Execf(shell string, args ...any) (string, error)
- func ExecfAsync(shell string, args ...any) error
- func ExecfWithContext(ctx context.Context, shell string, args ...any) (string, error)
- func ExecfWithDir(dir, shell string, args ...any) (string, error)
- func ExecfWithOutput(shell string, args ...any) error
- func ExecfWithPipe(ctx context.Context, shell string, args ...any) (io.ReadCloser, error)
- func ExecfWithTTY(shell string, args ...any) (string, error)
- func ExecfWithTimeout(timeout time.Duration, shell 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 命令并将输出写入指定的日志文件 ctx 取消时会杀死整个进程组
func ExecWithStdinProgress ¶ added in v3.3.1
func ExecWithStdinProgress( ctx context.Context, name string, args []string, stdin io.Reader, total int64, interval time.Duration, progress func(written, total int64, rate float64), ) (string, error)
ExecWithStdinProgress 以外部命令消费 stdin,同时按周期通过 progress 回调输出进度 name/args 为命令与参数; stdin 是被喂给命令的字节流; total 为已知总字节数(<=0 表示未知) interval 是进度回调周期; progress(written, total, rate) 中 rate 单位是 bytes/s pipe 存在背压,written 增速 ≈ 命令处理速率,可作为大概进度使用
func ExecfWithContext ¶ added in v3.3.1
ExecfWithContext 安全执行 shell 命令,ctx 取消时终止进程
func ExecfWithDir ¶
ExecfWithDir 在指定目录下执行 shell 命令
func ExecfWithOutput ¶
ExecfWithOutput 执行 shell 命令并输出到终端
func ExecfWithPipe ¶
ExecfWithPipe 执行 shell 命令并返回管道
func ExecfWithTTY ¶
ExecfWithTTY 在伪终端下执行 shell 命令
func ExecfWithTimeout ¶
ExecfWithTimeout 执行 shell 命令并设置超时时间
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 终端大小调整消息