Running command line on a remote machine using Jav

2019-09-08 15:39发布

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条回答
Deceive 欺骗
2楼-- · 2019-09-08 16:33

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
查看更多
登录 后发表回答