如何从 Putty 获取输入到 Java? [英] How to get input from Putty to Java?
问题描述
我对 Ubuntu 和 shell 编程很陌生.我正在使用 putty 在 Ubuntu 上执行 vmstat
和 iostat
命令.我需要在 java(Windows 环境)中执行这些命令并获得结果的 InputStream
.可能吗?
I am quite new to Ubuntu and shell programming. I am using putty to execute vmstat
and iostat
commands on Ubuntu. I need to execute those commands in java (Windows environment) and get an InputStream
of the result. Is it possible?
推荐答案
是的.使用 plink
(aPuTTY 后端的命令行界面).
Yes. Use plink
(a command-line interface to the PuTTY back end).
例如、
plink remote_host "ls -l"
我已经成功地使用它,从基于 Windows 的 TFS 构建,在 Linux 机器上执行 Android 构建.因此可以以编程方式处理 plink 的输出.
I've successfully used this to, from a Windows-based TFS Build, execute an Android build on a Linux box. So it's possible to work with the output from plink programatically.
这是一个示例,说明如何从 Java 内部调用 shell 命令.
Here's an example of how to call a shell command from within Java.
这篇关于如何从 Putty 获取输入到 Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!