Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do run ssh server "svn info /path/to/codebase" from php. It works fine but I wan to know how to check if the ssh login was not successful.

I want to check from my php script that ssh server is up and login process finished successfully. How can do that?

share|improve this question
up vote 3 down vote accepted

You can look at the return code from the ssh command. If the command fails, ssh will return a non-zero exit code. According to the PHP documentation, the system and exec functions both allow you to capture the return code of a command in the *return_var* parameter.

share|improve this answer

The return code is useful, but be aware that you can get a non-zero result if the ssh login succeeds but the remote command fails. If you don't expect svn info to fail once you've logged in, then this is no big deal.

share|improve this answer
Good point so I can check both output of svn info and return code of ssh itself. – Radek Feb 15 '12 at 3:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.