exec

package
v0.0.0-...-27d4b90 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2015 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecResponse

type ExecResponse struct {
	Code   int
	Stdout []byte
	Stderr []byte
}

ExecResponse contains the return code and output generated by executing a command.

func RunCommands

func RunCommands(run RunParams) (*ExecResponse, error)

RunCommands executes the Commands specified in the RunParams using powershell on windows, and '/bin/bash -s' on everything else, passing the commands through as stdin, and collecting stdout and stderr. If a non-zero return code is returned, this is collected as the code for the response and this does not classify as an error.

type RunParams

type RunParams struct {
	Commands    string
	WorkingDir  string
	Environment []string
	// contains filtered or unexported fields
}

Parameters for RunCommands. Commands contains one or more commands to be executed using bash or PowerShell. If WorkingDir is set, this is passed through. Similarly if the Environment is specified, this is used for executing the command.

func (*RunParams) Process

func (r *RunParams) Process() *os.Process

Process returns the *os.Process instance of the current running process This will allow us to kill the process if needed, or get more information on the process

func (*RunParams) Run

func (r *RunParams) Run() error

Run sets up the command environment (environment variables, working dir) and starts the process. The commands are passed into bash on Linux machines and to powershell on Windows machines.

func (*RunParams) Wait

func (r *RunParams) Wait() (*ExecResponse, error)

Wait blocks until the process exits, and returns an ExecResponse type containing stdout, stderr and the return code of the process. If a non-zero return code is returned, this is collected as the code for the response and this does not classify as an error.

Jump to

Keyboard shortcuts

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