exec

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package exec supplies some convenient execution functions.

Index

Constants

This section is empty.

Variables

View Source
var SSHOptions = "-o StrictHostKeyChecking=no"

SSHOptions is the options of ssh/scp command.

View Source
var SSHUser = "root"

SSHUser is the user to execute the shell command by SSH.

Functions

func CopyFilesFromRemoteBySSH added in v0.15.0

func CopyFilesFromRemoteBySSH(remoteHost, localDirOrFile string, remoteFiles ...string) error

CopyFilesFromRemoteBySSH copies the files from the remote to the local.

func CopyFilesToRemoteBySSH added in v0.15.0

func CopyFilesToRemoteBySSH(remoteHost, remoteDirOrFile string, localFiles ...string) error

CopyFilesToRemoteBySSH copies the files from the local to the remote.

func Execute

func Execute(name string, args ...string) error

Execute executes a command name with args.

func ExecuteCmdBySSH added in v0.15.0

func ExecuteCmdBySSH(host, cmd string) (stdout, stderr string, err error)

ExecuteCmdBySSH executes the shell command by SSH.

func ExecuteScriptBySSH added in v0.15.0

func ExecuteScriptBySSH(host, script string) (stdout, stderr string, err error)

ExecuteScriptBySSH executes the shell script by SSH.

func Executes

func Executes(cmds ...string) error

Executes is equal to Execute(cmds[0], cmds[1:]...).

func LogExecutedCmdResultHook

func LogExecutedCmdResultHook(name string, args []string, stdout, stderr []byte,
	err error) ([]byte, []byte, error)

LogExecutedCmdResultHook returns a hook to log the executed command.

func MustExecute

func MustExecute(name string, args ...string)

MustExecute is the same as Execute, but the program exits if there is an error.

func MustExecutes

func MustExecutes(cmds ...string)

MustExecutes is the equal to MustExecute(cmds[0], cmds[1:]...).

func MustOutput

func MustOutput(name string, args ...string) string

MustOutput is the same as Execute, but the program exits if there is an error.

func MustOutputs

func MustOutputs(cmds ...string) string

MustOutputs is the equal to MustOutput(cmds[0], cmds[1:]...).

func Output

func Output(name string, args ...string) (string, error)

Output executes a command name with args, and get the stdout.

func Outputs

func Outputs(cmds ...string) (string, error)

Outputs is equal to Output(cmds[0], cmds[1:]...).

func PanicExecute

func PanicExecute(name string, args ...string)

PanicExecute is the same as MustExecute, but panic instead of exiting.

func PanicExecutes

func PanicExecutes(cmds ...string)

PanicExecutes is the equal to MustExecute(cmds[0], cmds[1:]...).

func PanicOutput

func PanicOutput(name string, args ...string) string

PanicOutput is the same as MustOutput, but panic instead of exiting.

func PanicOutputs

func PanicOutputs(cmds ...string) string

PanicOutputs is the equal to MustOutput(cmds[0], cmds[1:]...).

func SetDefaultCmdLock added in v0.15.0

func SetDefaultCmdLock(lock *sync.Mutex)

SetDefaultCmdLock sets the lock of the default command executor to lock.

func SetDefaultCmdLogHook

func SetDefaultCmdLogHook()

SetDefaultCmdLogHook sets the log hook for the default command executor.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL