I have a go program that should call 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\n", err.Error()) os.Exit(1) } }
I call it like this:
runCommand("ruby", "-e", "require 'foo'")
It works in most cases, except when the child process has gets or any similar operation that must be paused for input.
I tried to set cmd.Stdin = os.Stdin , but it does not cmd.Stdin = os.Stdin for input.
What am I doing wrong?
go
Srikanth venugopalan
source share