Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
May 4, 2005

How To Perform a Telnet Operation from a Java Application

Follow these simple steps to perform a telnet operation from a Java application:
  1. Download the free API, jta20.jar.
  2. Set the file in the classpath:
    
    public class TestTelnet{
      public static void main(String args[]){
            //instantiate the telnet wrapper class
            TelnetWrapper telnetWrapper = new TelnetWrapper();
            try {
                //connect to the ipaddress
                telnetWrapper.connect("192.168.0.xxx", 23);
                //username and pwd of the ipaddress
                telnetWrapper.login("username", "pwd");
                //this is the prompt appears when doing normal ftp using cmd prompt.
                telnetWrapper.setPrompt("ftpprompt$");
               //wait for the prompt
               telnetWrapper.waitfor("bash-2.03$");
               //execute the commands
               System.out.println(telnetWrapper.send("ps -ef | grep java"));
            }catch(java.io.IOException e){
               e.printStackTrace();
            }
      }
    }
    

Elayaraja David
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date