Skip to content

Commit

Permalink
Pass stderr and stdout to parent stds
Browse files Browse the repository at this point in the history
  • Loading branch information
michaloo committed Aug 21, 2014
1 parent d8c8e55 commit 8b76d1d
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import "os/signal"
import "syscall"
import "github.com/robfig/cron"

func execute(command string, args []string)(output string, e error) {
func execute(command string, args []string)() {

println("executing:", command, strings.Join(args, " "))

cmd := exec.Command(command, args...)
out, err := cmd.Output()

if err != nil {
return "", err
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

return string(out), nil
cmd.Run()

cmd.Wait()
}

func create() (cr *cron.Cron, wgr *sync.WaitGroup) {
Expand All @@ -33,13 +33,8 @@ func create() (cr *cron.Cron, wgr *sync.WaitGroup) {

c.AddFunc(schedule, func() {
wg.Add(1)
out, err := execute(command, args)
execute(command, args)
wg.Done()
if err != nil {
println(err.Error())
}

println(out)
})

return c, wg
Expand Down

0 comments on commit 8b76d1d

Please sign in to comment.