-1

I am attempting to check the output of running the command "ssh -T [email protected]"

The output should look like:

Hi xyz! You've successfully authenticated, but GitHub does not provide shell access.

However, I am unable to capture this output. Where is this text coming from and how can I access it so I can test against it?

Piping the output or writing to a file yields no results.

ssh -T [email protected] | grep "successful"

Grep here receives no input.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Ampix0
  • 135
  • 1
  • 3
  • 11

1 Answers1

1

Error messages are usually written to a separate "stream" called StdErr.

You can redirect the StdErr output to be merged with the StdOut (output).

[email protected] 2>&1 | grep "successful"

Will solve your problem.

2>&1 
|| |
|| +-> 1 is the filehandle num assosciated with stdin
|+---> >& redirects from left to right, "merging" the 2 specified streams 
+===-> 2 is the filehandle number for stderr
shellter
  • 36,525
  • 7
  • 83
  • 90