在远程机器上使用Java运行命令行 [英] Running command line on a remote machine using Java

查看:181
本文介绍了在远程机器上使用Java运行命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在远程计算机上运行命令行(而不是在托管应用程序的服务器上运行)。

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

我理解 Runtime.getRuntime()。exec(..); 将尝试在服务器上运行脚本。

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?

推荐答案

Runtime.getRuntime() ).exec 机器上启动过程,而不是远程机器。该进程代表一个命令行界面是否将由运行的可执行文件和底层平台决定。

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:


  • 调用remoting类型命令,如rsh或ssh

  • 使用远程处理第三方库,例如 Jsch

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

这篇关于在远程机器上使用Java运行命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆