Output runs cmd on the remote host and returns its standard output.
(cmd string)
| 316 | |
| 317 | // Output runs cmd on the remote host and returns its standard output. |
| 318 | func (s *Session) Output(cmd string) ([]byte, error) { |
| 319 | if s.Stdout != nil { |
| 320 | return nil, errors.New("ssh: Stdout already set") |
| 321 | } |
| 322 | var b bytes.Buffer |
| 323 | s.Stdout = &b |
| 324 | err := s.Run(cmd) |
| 325 | return b.Bytes(), err |
| 326 | } |
| 327 | |
| 328 | type singleWriter struct { |
| 329 | b bytes.Buffer |