I've been trying to use a python utility from code that I'm writing in go. I've been trying to use stdin/stdout to communicate between the processes. However, I'm getting an EOF error using python's raw_input(), even if I connect its stdin to go's stdin.
Here is the code to reproduce the issue:
test.go:
package main
import (
"os"
"os/exec"
)
func main() {
cmd := exec.Command("python", "test.py")
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
// Start the process
if err := cmd.Start(); err != nil {
panic(err)
}
}
test.py:
while True:
input = raw_input()
print input
The error I get is
Traceback (most recent call last):
File "test.py", line 3, in <module>
input = raw_input()
EOFError
I don't understand why this would be an issue. Does anybody have any input?