Documentation
¶
Overview ¶
The main difference is that the process does not wait for child processes to finish. This is useful for running long-running processes that are expected to run in the background.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct { // Path is the path of the command to run. // // This is the only field that must be set to a non-zero // value. If Path is relative, it is evaluated relative // to Dir. Path string // Args holds command line arguments, including the command as Args[0]. // If the Args field is empty or nil, Run uses {Path}. // // In typical use, both Path and Args are set by calling Command. Args []string // Process is the underlying process, once started. Process *os.Process // ProcessState contains information about an exited process. // If the process was started successfully, Wait or Run will // populate its ProcessState when the command completes. ProcessState *os.ProcessState // contains filtered or unexported fields }
Cmd represents an external command being prepared or run.
A Cmd cannot be reused after calling its Output or CombinedOutput methods.
func Command ¶
Command returns the Cmd struct to execute the named program with the given arguments.
It sets only the Path and Args in the returned structure.
func (*Cmd) CombinedOutput ¶
CombinedOutput runs the command and returns its combined standard output and standard error.
Example ¶
package main import ( "fmt" "log" "github.com/mrmarble/exec" ) func main() { out, err := exec.Command("/bin/sh", "-c", "echo stdout; echo 1>&2 stderr").CombinedOutput() if err != nil { log.Fatal(err) } fmt.Printf("Output: %s\n", out) }
Output: Output: stdout stderr
Click to show internal directories.
Click to hide internal directories.