Stephanie
Stephanie

Reputation: 31

Run a process on Linux remotely from a Windows machine

I would like to be able to run a process that exists on a Linux machine remotely from a JAVA application running on a Windows machine. What is the best way to do this? Or an online resource that might be of help to me? Thanks very much.

Upvotes: 3

Views: 1587

Answers (5)

Somye
Somye

Reputation: 87

You can use ssh command to login into a sytem example..

     String[] cm = {
                   "ssh",
                   "username@hostIP" ,
                   "your command"

                   };

     try
      {
       Process q=  Runtime.getRuntime().exec(cm);
       q.waitFor();
      }
    catch(Exception e) {}

Upvotes: 0

user167210
user167210

Reputation:

You can also make a kind of client/server architecture. Your Java client will send a command to your Java server (~ webservice), that will execute the desired process. But obviously, it depends on your aims. Do you need to do that in a secure way? Is it through the internet or inside a local network? And finally, is the process a Java process?

Upvotes: 0

Pascal Thivent
Pascal Thivent

Reputation: 570615

  1. Expose the process as a [fire and forget] web service on the Linux machine.
  2. Call it from the windows machine.

Upvotes: 0

Alex Martelli
Alex Martelli

Reputation: 882781

You could use any of the many Java SSH client libraries, such as javassh, as long as the Linux machine runs an sshd (and the firewalls are all set to let ssh traffic through), which is likely to be the case. There are many possible ways to configure ssh authentication, basically boiling down to either sending password (securely) on the net, or using public/private key pairs (RSA or DSA) -- the latter is generally preferable, but you'll need to check with system and network administrators about this issue... it's not really a software development issue, but rather one related to system administration and security.

Upvotes: 5

Steven
Steven

Reputation: 13769

In short, use an ssh client.

Option 1: Install openssh package in Cygwin.

Option 2: Use Putty.

In either case, you can setup a keypair to allow for automatic (non-password) authentication.

Upvotes: 1

Related Questions