-1

I am attempting to check the output of running the command "ssh -T git@github.com"

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 git@github.com | grep "successful"

Grep here receives no input.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Ampix0
  • 135
  • 1
  • 3
  • 11
  • 2
    try `ssh -T git@github.com 2>&1| grep successful`. Good luck. – shellter Jul 20 '19 at 02:52
  • 1
    Thank you @shellter! And for other people arriving who will probably have the same next question as me: https://stackoverflow.com/questions/818255/in-the-shell-what-does-21-mean – Ampix0 Jul 20 '19 at 04:07
  • @shellter, can you add the same as an answer so that ampix can accept it. It will mark the question as answered. – Mihir Luthra Jul 20 '19 at 05:59

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).

git@github.com 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