0

I have a windows machine which connects to a remote Linux machine where my Java program is running. How could I run a command for example, "free -m" in the remote linux machine and collects data in the windows machine. Any strategy?

user84592
  • 4,750
  • 11
  • 55
  • 91
  • You'll need to be more specific: do you need to run the program from within your JVM? Or via an `ssh` session? Or just have some predetermined commands run and send their data to the windows machine via any mechanism whatever for further analysis? There's many ways this could be done, and without more requirements, it'll be hard to make any recommendations. – sarnold Jun 24 '11 at 08:25

4 Answers4

2

You can execute Linux command from java program remotely using Jsch and expect4j.
For example, look at this question.

Community
  • 1
  • 1
Nikunj
  • 3,100
  • 2
  • 20
  • 19
1

You can use ssh user@host free -m. Just get some ssh client for windows. I personally prefer cygwin which will also give you a nice way to script it using bash.

Alex Gitelman
  • 24,429
  • 7
  • 52
  • 49
1

If you use anything except jsch, you run the risk of blasphemy :)

Suraj Chandran
  • 24,433
  • 12
  • 63
  • 94
0

I have previously used Trilead SSH which was great and simple to use. Unfortunately Trilead don't support it anymore, however according to this site (lots of SSH links there) the ex-Trilead version is now here.