Solved

Connect to a remote shell and run command in Java

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 73
oracle query help 18 100
This code tracks birthdays 3 62
SCRIPT65535: Unexpected call to method or property access video html 5 explorer 3 49
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

20 Experts available now in Live!

Get 1:1 Help Now