Hi folks,
I have only been using Go for about a month, so any help would be greatly appreciated.
I am working on a little application that uses the exec.Command to run an ssh process
to a remote host. Everything is working fine, up until the time the process that invokes
exec.Command tries to write back to the ssh process. There is no actual error that I can
find, but the receiving process reads 0 bytes. Here is an general description of what
is going on:
// On the sending host:
cmd.Stdin = strings.NewReader("Hello, how are you")
var remoteStdout bytes.Buffer // A buffer to hold the remote command's stdout.
var remoteStderr bytes.Buffer // A buffer to hold the remote command's stdout.
cmd.Stdout = &remoteStdout // The remote command's stdout.
cmd.Stderr = &remoteStderr // The remote command's stderr.
err = cmd.Run()
response := remoteStdout
fmt.Fprintf(os.Stderr, "Response: %s\n", response)
cmd.Stdin = strings.NewReader("Ok, Goodbye")
// On the receiving host:
data, err := ioutil.ReadAll(os.Stdin)
fmt.Fprintf(os.Stderr, "Read %d bytes of type: %T from stdin\n", len(data), data)
os.Stdout.WriteString("Hello, I'm fine, thanks.")
data, err := ioutil.ReadAll(os.Stdin)
At which point the receiver reports that it has read 0 bytes.
I have read the documentation, searched for examples, googled up and down until I've read
most everything found, without any luck. Any help would be greatly appreciated. I am really
enjoying working with Go.
Best Regards,
Daryl