exec

package
v0.0.0-...-3b86d9c Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2019 License: Apache-2.0 Imports: 8 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(command ...string) *exec.Cmd

Command returns a Cmd from a shell command.

func CommandContext

func CommandContext(ctx context.Context, command ...string) *exec.Cmd

CommandContext returns a Cmd with the given context and shell command.

func FullOutput

func FullOutput(c *exec.Cmd) (stdout []byte, stderr []byte, code int, err error)

FullOutput runs a command and returns its stdout, stderr, exit code, and error status.

func SimpleFullOutput

func SimpleFullOutput(timeout time.Duration, command ...string) (stdout []byte, stderr []byte, code int, err error)

SimpleFullOutput runs a shell command with a timeout and returns its stdout, stderr, exit code, and error status.

Types

type CommandExecutor

type CommandExecutor struct {
	Done chan error
	// contains filtered or unexported fields
}

CommandExecutor is a structure returned by exec.Run Cancel can be used by a user to interrupt a command execution. Done is a channel the user can read in order to retrieve execution status. Possible statuses:

<nil> command executed successfully, returned 0 exit code
<exit status N> where N is non 0 exit status.
<context deadline exceeded> means timeout was reached and command was killed.
<context canceled>  means that command was canceled by a user.

func Run

func Run(ctx context.Context, command string, arg []string) (*CommandExecutor, error)

Run spawns the given command and returns a handle to the running process in the form of a CommandExecutor.

func (*CommandExecutor) Read

func (c *CommandExecutor) Read(p []byte) (int, error)

Read implements the io.Reader. CommandExecutor will read from stdout and stderr

Jump to

Keyboard shortcuts

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