[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 585
  • Last Modified:

Connect to a remote shell and run command in Java

Hi,

Does anyone knows how use Java code to connect to a remote shell (linx), and run some commands such as "ls"? Thanks.

0
huabin
Asked:
huabin
  • 2
1 Solution
 
rongasaCommented:
I would suggest to create a server/client application. The remote client would send through a socket to the server (in linux/unix) the desired command to be executed. Then the server would execute the respective code, as a normall local command.
I hope my idea help you.
0
 
kjpusCommented:
If all you need to do is to execute a command at a remote server, you may want to take a look at those java implementaions of SSH client. Pretty much all linux distributions have SSH server included; that takes care of the remote side. All you need to do is to inject the command into the java SSH client. Here a link for java SSH implementaions:http://linuxmafia.com/ssh/java.html
0
 
rongasaCommented:
I think his solution is better than mine...
I suggest that you follow kjpus solution, i did not this...
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now