As the descrption say it returns a read end of the pipe. However i was expecting it to assign the write end to sesssion.Stdout
. Lets say I want to redirect stderr to same pipe for common reader consumption.
Example: sesssion.Stderr = session.Stdout
. But after StdoutPipe()
, sesssion.Stdout
is still nil
I’m I missing something here?
// StdoutPipe returns a pipe that will be connected to the
// remote command's standard output when the command starts.
// There is a fixed amount of buffering that is shared between
// stdout and stderr streams. If the StdoutPipe reader is
// not serviced fast enough it may eventually cause the
// remote command to block.
func (s *Session) StdoutPipe() (io.Reader, error) {
if s.Stdout != nil {
return nil, errors.New("ssh: Stdout already set")
}
if s.started {
return nil, errors.New("ssh: StdoutPipe after process started")
}
s.stdoutpipe = true
return s.ch, nil
}