Solved

Connect to a remote shell and run command in Java

Posted on 2006-06-27
5
573 Views
Last Modified: 2012-06-27
Hi,

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

0
Comment
Question by:huabin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 1

Expert Comment

by:rongasa
ID: 17000100
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
 
LVL 2

Accepted Solution

by:
kjpus earned 500 total points
ID: 17002931
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
 
LVL 1

Expert Comment

by:rongasa
ID: 17017782
I think his solution is better than mine...
I suggest that you follow kjpus solution, i did not this...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Progress

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question