title: Apache Mina SSH: Client to interact with the server
body: <p>I am writing a program where I can send a shell command to the server and work on its response. I looked at this <a href="http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ClientTest.java" rel="nofollow">TestCase</a> (testClient()) and managed to connect and send some commands. However I receive the response only after the call to <code>channel.waitFor(ClientChannel.CLOSED, 0);</code> and this method returns only when "exit" has been sent to the server. </p>
  
  <p>How can I make a normal SSH interaction as if I am using PUTTY but have java do something with the response like for example, cd to a folder, list the files, if an interesting folder is found cd to that folder, if a file with a certain filename is found, do some grep, etc etc?</p>