diff --git a/command/command_factory.go b/command/command_factory.go index f2e1fc8..307469a 100644 --- a/command/command_factory.go +++ b/command/command_factory.go @@ -2,6 +2,8 @@ package command import ( "os/exec" + "log" + "io" ) type CommandFactory struct { @@ -10,5 +12,20 @@ type CommandFactory struct { } func (me CommandFactory) Create(body string) *exec.Cmd { - return exec.Command(me.Cmd, append(me.Args, body)...) + cmd := exec.Command(me.Cmd, me.Args...) + + stdin, err := cmd.StdinPipe() + + if err != nil { + log.Fatal(err) + } + + go func() { + if(len(body) > 0) { + defer stdin.Close() + io.WriteString(stdin, body) + } + }() + + return cmd }