Documentation ¶
Index ¶
- func CheckCmd(cmd string) bool
- func GetUserInfo(display bool) (ok bool, username string, userid int, UserHome string)
- func Version() string
- type ApiHandle
- type ApiShell
- func (api *ApiShell) AwkCol(col string)
- func (api *ApiShell) Column(col int, sep string) *ApiShell
- func (api *ApiShell) Echo()
- func (api *ApiShell) Grep(match string) *ApiShell
- func (api *ApiShell) Line(n int) *ApiShell
- func (api *ApiShell) RunScript(command ...string)
- func (api *ApiShell) RunShell(command ...string)
- func (api *ApiShell) RunShellList(cs []string)
- func (api *ApiShell) RunTerminal(command ...string)
- func (api *ApiShell) RunTimeout(n time.Duration, command ...string) *ApiShell
- type ApiSudo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUserInfo ¶
GetUserInfo 获取用户名,用户uid,用户家目录
Types ¶
type ApiShell ¶ added in v1.4.7
type ApiShell struct { PrintErr bool // 打印详细错误信息(默认: true) PrintInfo bool // 是否打印详细信息(默认: false) Debug bool // 是否打印调试信息(默认: false) Realtime bool // 是否开启实时打印信息 Result bool // 是否执行成功 Text string // 需要执行的命令 OsType string // 系统类型 Strings string // 输出结果 ExitCode int // 命令执行退出代码 Err error // 错误 Slice []string // 数据切片 Script string // 脚本文件 ScriptMode bool // 脚本文件 Terminal string // 使用的终端命令 TerminalArg string // 使用的终端参数 TerminalBool bool // 是否可以使用终端 BlackHole bool // 是否使用黑洞模式(忽略错误信息) Ignore bool // 是否忽略标准输出 // contains filtered or unexported fields }
ApiShell 定义命令的结构体
func (*ApiShell) RunShellList ¶ added in v1.7.7
RunShellList 批量执行命令
func (*ApiShell) RunTerminal ¶ added in v1.7.8
RunTerminal 通过调用图形化终端程序的方式执行Shell命令,使用脚本封装的方式,支持Shell管道
type ApiSudo ¶ added in v1.4.7
type ApiSudo struct { //PrintErr bool // 打印详细错误信息(默认: true) //PrintInfo bool // 是否打印详细信息(默认: false) //Debug bool // 是否打印调试信息(默认: false) //home string // 当前用户家目录(自动判断) //user string // 当前用户名(自动判断) //uid int // 当前用户uid(自动判断) //Realtime bool // 是否开启实时打印信息 //Result bool // 是否执行成功 //Text string // 需要执行的命令 //OsType string // 系统类型 //Err error // 错误 //gfs gf.ReadScreen // 文本处理实例 //args []string // 执行参数 //Strings string // 输出结果 //ExitCode int // 命令执行退出代码 //Slice []string // 数据切片 //Script string // 脚本文件 //ScriptMode bool // 脚本文件 //Shell ApiShell // 实例化Shell SudoPath string // sudo命令绝对路径 Password string // sudo权限使用的密码 ApiShell // 继承Shell实例 // contains filtered or unexported fields }
ApiSudo 定义命令的结构体
func NewSudo ¶ added in v1.4.6
NewSudo 命令实例构造函数, 当不需要执行sudo命令的时候直接传入任意字符串给password即可 Realtime 是否开启实时打印数据
func (*ApiSudo) RunScriptSudo ¶ added in v1.7.0
RunScriptSudo 通过生成脚本的方式执行Shell,支持Shell管道
func (*ApiSudo) RunSudoList ¶ added in v1.7.7
RunSudoList 批量执行命令
Click to show internal directories.
Click to hide internal directories.