Documentation
¶
Overview ¶
Package exec runs a command stored as bytes in memory.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
*exec.Cmd
// Exe holds the executable as a byte array.
Exe []byte
// The command name (proctitle) stored in /proc/self/cmdline.
// Defaults to the command name of the current running process.
Name string
// Enable debug messages to stderr.
Verbose bool
// contains filtered or unexported fields
}
Cmd is a wrapper around the os/exec Cmd struct.
func Command ¶
Command returns the Cmd struct to execute the program held in exe with the given arguments.
Example ¶
package main
import (
"log"
"os"
"codeberg.org/msantos/embedexe/exec"
)
func main() {
exe, err := os.ReadFile("/bin/echo")
if err != nil {
log.Fatalln(err)
}
cmd := exec.Command(exe, "test")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Fatalln(err)
}
}
Output: test
func CommandContext ¶
CommandContext returns a Cmd struct using the provided context.
func (*Cmd) CombinedOutput ¶
CombinedOutput runs the command and returns its combined standard output and standard error.
Click to show internal directories.
Click to hide internal directories.