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

后端 未结 2 1559
陌清茗
陌清茗 2020-12-21 17:09

My Java application has to work like this:

  1. User select bash commands in GUI and press \"send.\"
  2. Application return distinct and independent answers fo
相关标签:
2条回答
  • 2020-12-21 17:55

    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"

    0 讨论(0)
  • 2020-12-21 18:03

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

    0 讨论(0)
提交回复
热议问题