Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
148 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...