SSH in Java App with 'expect' like functionality [closed]

久未见 提交于 2019-12-05 20:25:51

问题


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


回答1:


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.




回答2:


Yes, it's possible. There are some libraries, but I suggest Ganymed SSH-2. You can download it here, and there are also a lot of examples of using functions...




回答3:


Try ExpectJ.   



来源:https://stackoverflow.com/questions/6394836/ssh-in-java-app-with-expect-like-functionality

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!