Java library to run multiple unrelated commands on a remote server via ssh

倾然丶 夕夏残阳落幕 提交于 2019-11-29 16:05:11

You should use ExpectJ, a Java implementation of the Unix expect utility.

not sure if you still have the problems, in any case, it might contribute to other people.

ExpectJ is indeed the Java implementation of Unix expect. and you should definitely buy the "explore expect book" then look into it, it is worth it.

For your question: when you spawn a process, you listen to the return output, match it to a prompt, then send some command. if you want to analyze the output, you buffer that output, and do some actions before the next send()

to do so, you need to use the interact() method of the spawn class you used. http://expectj.sourceforge.net/apidocs/index.html

and for interact and how it works: http://oreilly.com/catalog/expect/chapter/ch03.html look for this part: "The interact Command"

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