Solved

How to I run a small Telnet script in Linux from Java and get back the result?

Posted on 2008-10-30
4
1,192 Views
Last Modified: 2012-08-13
Thank you
0
Comment
Question by:kerzner
  • 2
4 Comments
 
LVL 10

Expert Comment

by:kyleb84
ID: 22845973
You want to connect to somewhere via Telnet, but the Telnet client is in Java?
You want this to be a non-interactive procedure?

You'll need a java Telnet client, there's plenty around - then you need to gut it and take out the Telnet protocol handling.

Then you'll need to add on to that class providing automated read/write functions for your application.

It's a fair bit of work but possible.

For a start, here's a Telnet/SSH client in java, source code available.

http://javassh.org/space/start

0
 
LVL 12

Accepted Solution

by:
basav_com earned 500 total points
ID: 22876504
You have to use expectJ here.
http://expectj.sourceforge.net/

More info:
ExpectJ is a Java implementation of the Unix expect utility. ExpectJ provides a Unix expect like support to write Java Programs that communicate with other programs and perform some operation on them.
If you are not familiar with working of the Unix expect utility, please refer to man page of expect. Usage of ExpectJ requires a proper understanding of the Unix expect utility.
For example using ExpectJ you can write a Java program that telnets to a host machine and deletes the contents of /tmp. This program when configured as a cron job will always keep the /tmp under the specified limit.
0
 
LVL 1

Author Comment

by:kerzner
ID: 22876906
kyleb84, the reason I am going this way is because Telnet, when I use it standalone, did work properly. My Java code did not. So I plan to wrap the use of Telnet. I will try your approach if ExpectJ does not work out.
0
 
LVL 1

Author Comment

by:kerzner
ID: 22876918
basav_com,

it sounds like what I need, and I will use it first thing tonight. I vaguely remember having used Unix expect with good results.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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 …

746 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