Documentation ¶
Overview ¶
Package cmd
Package cmd ¶
Package cmd ¶
Package cmd 系统调用exec包 ¶
实现了命令的快速调用 使用New()创建一个Cmder对象 c := NewCmder() c.Exec("ls")
实现了基于windows/linux的daemon模式启动 cmd.Daemon() 或 cmd.DaemonCall(cmd)调用任意命令
Index ¶
- Constants
- Variables
- func Daemon(exclude string)
- func DaemonCall(program string, args ...string) error
- func DaemonWith(exclude string) (int, error)
- func Fork(arg0 string, argv []string, attr *syscall.ProcAttr) (int, error)
- func InitCmder(shell string)
- func NewBash(dst, sh string) error
- func NewEmptyBash(dst string) error
- type Cmder
- func (c Cmder) Exec(sh string) error
- func (c Cmder) ExecAsync(sh string, ctx context.Context) error
- func (c Cmder) ExecCtx(sh string, ctx context.Context) ([]byte, error)
- func (c Cmder) ExecOpt(sh string) ([]byte, error)
- func (c Cmder) ExecStr(sh string) (string, error)
- func (c Cmder) Run(sh string) *exec.Cmd
- func (c Cmder) RunContext(sh string, ctx context.Context) *exec.Cmd
Constants ¶
View Source
const ( Bash = "bash" Zsh = "zsh" Fish = "fish" Sh = "sh" )
View Source
const ( BASH = ".sh" ShellPerm = 0700 EmptyBash = "#!/usr/bin/env bash" )
View Source
const (
DefaultMask = 0117 // 默认0660
)
Variables ¶
View Source
var Cmd = Cmder{/* contains filtered or unexported fields */}
Functions ¶
func Daemon ¶ added in v1.1.5
func Daemon(exclude string)
Daemon 以daemon模式运行当前的程序 限制需要指定daemon arg来用于排除
func DaemonCall ¶ added in v1.1.5
DaemonCall daemon调用任意指定的命令
func NewEmptyBash ¶
NewEmptyBash 新建一个空shell文件 dst为文件生成的目录 dst为.sh结尾的文件
Types ¶
Click to show internal directories.
Click to hide internal directories.