Solved

Connect to a remote shell and run command in Java

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object oriented design (python) and documentation tools 2 139
printf performancy 11 104
How to share My.Settings in multiple application instances ? 7 78
MySQL programmer starter 25 64
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…

734 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