Documentation
¶
Index ¶
- func CheckCmd(cmd string) bool
- func GetUserInfo(display bool) (ok bool, username string, userid int, UserHome string)
- func Version()
- func WriteTxtCover(text, filename string, wrap bool) (res bool, err error)
- 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) SudoBase() (int, string, error)
- func (shells *ShellConfig) System() (code int, out string, err error)
- func (shells *ShellConfig) WriShellFile(txt string) bool
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) SudoBase ¶ added in v1.3.1
func (shells *ShellConfig) SudoBase() (int, string, error)
SudoBase 通过Sudo执行脚本
func (*ShellConfig) System ¶ added in v1.3.1
func (shells *ShellConfig) System() (code int, out string, err error)
System 执行命令并支持实时获取输出,和Python的os.system函数一样,返回退出代码 command 需要执行的命令 realtime 是否开启实时打印
func (*ShellConfig) WriShellFile ¶ added in v1.3.1
func (shells *ShellConfig) WriShellFile(txt string) bool
WriShellFile 写入执行语句到文件
Click to show internal directories.
Click to hide internal directories.