Solved

Connect to a remote shell and run command in Java

Posted on 2006-06-27
5
555 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This is an explanation of a simple data model to help parse a JSON feed
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now