func StdExecve(argv []string, stopOnTrouble bool) bool { var err os.Error var cmd *exec.Cmd switch len(argv) { case 0: if stopOnTrouble { log.Fatalf("[ERROR] len(argv) == 0\n") } return false case 1: cmd = exec.Command(argv[0]) default: cmd = exec.Command(argv[0], argv[1:]...) } // pass-through cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Stdin = os.Stdin err = cmd.Start() if err != nil { if stopOnTrouble { log.Fatalf("[ERROR] %s\n", err) } else { log.Printf("[ERROR] %s\n", err) return false } } err = cmd.Wait() if err != nil { if stopOnTrouble { log.Fatalf("[ERROR] %s\n", err) } else { log.Printf("[ERROR] %s\n", err) return false } } return true }
/* Set up a command to use os standard in/out/err */ func set_exec(c *exec.Cmd) { c.Stdout = os.Stdout c.Stdin = os.Stdin c.Stderr = os.Stderr }