0

I want check ssh session disconnect at sometime in a program.
In the stage, I'm check response stream match the disconnect template to decide connection is closed.The template could be:
Timeout, server xxx.xxx.xxx.xxx not responding. and packet_write_wait: Connection to xxx.xxx.xxx.xxx port 22: Broken pipe

Is there others message could be print?

LoranceChen
  • 2,453
  • 2
  • 22
  • 48
  • Possible duplicate of [How to create a bash script to check the SSH connection?](https://stackoverflow.com/questions/1405324/how-to-create-a-bash-script-to-check-the-ssh-connection) – ivan_pozdeev Nov 04 '17 at 09:25

1 Answers1

0

It's unreliable to parse ssh output as it's flavor, locale and version-specific. It can also recite system error messages ("Broken pipe" in your case) which are, naturally, OS-specific.

Instead, check for exit status 255.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152