2021-08-04 11:04:01 +00:00
|
|
|
package config
|
|
|
|
|
2021-08-06 13:29:24 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
|
|
|
)
|
2021-08-04 11:04:01 +00:00
|
|
|
|
|
|
|
type Command struct {
|
|
|
|
Program string
|
|
|
|
Arguments []string
|
|
|
|
AppendPayload bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Command) Execute(payload string) ([]byte, error) {
|
|
|
|
arguments := make([]string, 0)
|
|
|
|
copy(c.Arguments, arguments)
|
|
|
|
if c.AppendPayload {
|
|
|
|
arguments = append(arguments, payload)
|
|
|
|
}
|
|
|
|
|
|
|
|
return exec.Command(c.Program, arguments...).Output()
|
|
|
|
}
|
2021-08-06 13:29:24 +00:00
|
|
|
|
|
|
|
func (c Command) String() string {
|
|
|
|
return fmt.Sprintf(
|
|
|
|
"<Command cmd=%v AppendPayload=%v>",
|
|
|
|
append([]string{c.Program}, c.Arguments...),
|
|
|
|
c.AppendPayload,
|
|
|
|
)
|
|
|
|
}
|