Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.