Documentation ¶
Index ¶
- func CheckCmd(cmd string) bool
- func GetUserInfo(display bool) (ok bool, username string, userid int, UserHome string)
- func Version()
- type ShellConfig
- func (shells *ShellConfig) GetStatusOutputBool(cmd string) (bool, string)
- func (shells *ShellConfig) Shell(command string) bool
- func (shells *ShellConfig) ShellGetOutSudo(cmd string) (string, error)
- func (shells *ShellConfig) ShellSudo(command string) bool
- func (shells *ShellConfig) ShellSystem(command string) (code int)
- func (shells *ShellConfig) SudoBaseSh() (int, string, error)
- func (shells *ShellConfig) SudoBaseTxt() (int, string, error)
- func (shells *ShellConfig) System() (code int, out string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUserInfo ¶
GetUserInfo 获取用户名,用户uid,用户家目录
Types ¶
type ShellConfig ¶ added in v1.2.0
type ShellConfig struct { SudoPath string // sudo命令绝对路径 ShellFile string // 生成的Shell脚本 // contains filtered or unexported fields }
ShellConfig 定义命令的结构体
func ShellInit ¶
func ShellInit(password string, realtime bool) *ShellConfig
ShellInit 命令实例构造函数, 当不需要执行sudo命令的时候直接传入任意字符串给password即可 realtime 是否开启实时打印数据
func (*ShellConfig) GetStatusOutputBool ¶ added in v1.2.0
func (shells *ShellConfig) GetStatusOutputBool(cmd string) (bool, string)
GetStatusOutputBool 执行命令并获取输出数据, 返回执行结果布尔值 - (成功/失败)及 命令输出 (字符串)
func (*ShellConfig) Shell ¶ added in v1.2.0
func (shells *ShellConfig) Shell(command string) bool
Shell 执行命令并获取执行结果, 返回执行结果(成功/失败)
func (*ShellConfig) ShellGetOutSudo ¶ added in v1.2.0
func (shells *ShellConfig) ShellGetOutSudo(cmd string) (string, error)
ShellGetOutSudo 通过Sudo权限执行命令并获取输出数据, 返回执行结果(成功/失败)及命令输出(字符串)
func (*ShellConfig) ShellSudo ¶ added in v1.2.0
func (shells *ShellConfig) ShellSudo(command string) bool
ShellSudo 执行命令并获取执行结果, 返回执行结果(成功/失败)
func (*ShellConfig) ShellSystem ¶ added in v1.3.1
func (shells *ShellConfig) ShellSystem(command string) (code int)
ShellSystem 执行命令并实时获取输出,和Python的os.system函数一样,返回退出代码
func (*ShellConfig) SudoBaseSh ¶ added in v1.3.3
func (shells *ShellConfig) SudoBaseSh() (int, string, error)
SudoBaseSh 通过Sudo执行脚本
func (*ShellConfig) SudoBaseTxt ¶ added in v1.3.3
func (shells *ShellConfig) SudoBaseTxt() (int, string, error)
SudoBaseTxt 通过Sudo执行命令
Click to show internal directories.
Click to hide internal directories.