Running command line on a remote machine using Java

独自空忆成欢 提交于 2019-12-11 23:06:00

问题


Is it possible to run command line on a remote machine (not on the server machine where the application is hosted).

I understand Runtime.getRuntime().exec(".."); will try to run the script on the server machine. Is my understanding correct and is there a way to achieve what I need?


回答1:


Runtime.getRuntime().exec launches a process on the local machine, not a remote one. Wether that process represents a command line interface or not will be determined by the executable that's run, and the underlying platform.

In order to invoke processes on remote machines you need to:

  • Invoke a remoting type command, like rsh or ssh
  • Utilize a remoting third party library, like Jsch


来源:https://stackoverflow.com/questions/15329244/running-command-line-on-a-remote-machine-using-java

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