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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes. Use plink
(a command-line interface to the PuTTY back end).
For example,
plink remote_host "ls -l"
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.
Here's an example of how to call a shell command from within Java.