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