SSH in Java App with 'expect' like functionality

jtnire picture jtnire · Jun 18, 2011 · Viewed 8.5k times · Source

With 'expect', one can execute SSH commands and parse the output of those commands to alter program flow. I'd like to do this with Java. That is, I want my Java app to launch a SSH session, execute a command on the remote server, and depend on the output of that command execute the next command, without needing to start a new SSH session.

Is this possible in Java?

Thanks

Answer

Ronnie picture Ronnie · Feb 28, 2013

Self-promoting my project: after looking at other Java-based Expect libraries, I decided to write my own... hope you find it useful. Please open issues in GitHub if you find any problem.

https://github.com/ronniedong/Expect-for-Java

For SSH, I suggest using JSch, as the example in the readme file.