GO: Is there some way to communicate with a subprocess (shell script / python script), which is waiting for input on stdin?
e.g. python script (subprocess)
import sys
while True:
sys.stdout.write('%s\n'%eval(sys.stdin.readline()))
In the go program, I want to create a subprocess of this python script and provide it input on its stdin, whenever necessary and repeatedly, and take its output. Writing on stdout of Go program or reading/writing from a file will also do.
This is roughly what I am trying, but nothing happens -
c := exec.Command("python", "-u add.py")
si,_ := c.StdinPipe()
so,_ := c.StdoutPipe()
c.Start()
si.Write([]byte("2+2\n")