Documentation
¶
Index ¶
- func RunReturnAll(command string, timeout int) (int, string, string, error)
- func RunReturnExitCode(command string, timeout int) (int, error)
- func RunReturnStdout(command string, timeout int) (string, error)
- func RunSSHCommand(config SSHConfig, command string, timeout int) (int, string, string, error)
- func RunWithRetries(cmd string, numRetries int, timeout int) int
- type CircularBuffer
- type SSHConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunReturnAll ¶
RunReturnAll executes a command and returns its exit code, stdout, stderr, and any error.
Params:
- command: the command string to execute
- timeout: timeout in seconds (0 for no timeout)
Returns: (exitCode, stdout, stderr, err)
- exitCode:命令的退出码(0 表示成功,非零表示命令失败或超时等)
- stdout:标准输出
- stderr:标准错误
- err:执行过程中遇到的错误(如管道创建失败、命令启动失败、超时等)。若命令以非零退出码结束,err 为 nil
- 管道创建或命令启动失败时,返回退出码 125 和具体的 error
- 超时情况下,返回退出码 124 和 err = "command timed out"
- 命令以非零退出码结束时,返回该退出码,err 为 nil
- 其他未预期的错误通过 err 返回,退出码为 125
func RunReturnExitCode ¶
RunReturnExitCode ...
func RunReturnStdout ¶
RunReturnStdout ...
func RunSSHCommand ¶
RunSSHCommand executes command via SSH with full lifecycle management
Types ¶
type CircularBuffer ¶
type CircularBuffer struct {
// contains filtered or unexported fields
}
CircularBuffer 实现固定大小的环形缓冲区
func NewCircularBuffer ¶
func NewCircularBuffer(size int) *CircularBuffer
NewCircularBuffer 创建一个新的环形缓冲区
type SSHConfig ¶
type SSHConfig struct {
User string
Host string
Port int
KeyPath string // Path to private key file, empty for default (~/.ssh/id_rsa)
Password string // Optional, if using password auth
Background bool // If true, run command in background and return PID
UseHomeTmp bool // If true, use ${HOME}/tmp instead of /tmp for temporary files
}
SSHConfig defines SSH connection parameters.
Click to show internal directories.
Click to hide internal directories.