I have a go program that should invoke a ruby script.
I have a runCommand
function:
func runCommand(cmdName string, arg ...string) {
cmd := exec.Command(cmdName, arg...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
err = cmd.Run()
if err != nil {
fmt.Printf("Failed to start Ruby. %s
", err.Error())
os.Exit(1)
}
}
I invoke it like this:
runCommand("ruby", "-e", "require 'foo'")
It works for most cases, except if there is a gets
or any similar operation in the child process that needs to pause for an input.
I have tried setting cmd.Stdin = os.Stdin
, but it does not wait for input.
What am I doing wrong?