Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:18:45+00:00 2026-05-25T12:18:45+00:00

I have looked at several questions here about using Java to drive a telnet

  • 0

I have looked at several questions here about using Java to drive a telnet session, and although I see some code down at the socket/protocol level, and a few recommendations for this or that telnet library, I don’t see sample code or a pointer to sample code for driving a telnet session using one of those libraries. There’s no reason why it can’t be this easy:

MyTel session = new MyTel("host.myco");
session.start();
session.waitForThenType("login:", "imauser");
session.waitForThenType("Password:","secr3et");
String output = session.waitForThenType("Solaris", "tail MyFile.txt");
session.waitForThenType("%>","exit");
session.end();
// enjoy output here

So, looking for some example code that stays out of the telnet sockets and protocol, but can drive telnet sessions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:18:47+00:00Added an answer on May 25, 2026 at 12:18 pm

    Which Java Telnet or openSSH library?

    http://sadun-util.sourceforge.net/telnet_library.html

    The sadun code is part of a larger set of utilities. What you need are these files:

    com.deltax.util (all)
    org.sadun.util.tp (all)
    org.sadun.util
    > Cache.java
    > ClassResolver.java
    > OperationTimedoutException.java
    > TelnetInputStream.java
    > TelnetInputStreamConsumer.java
    > TelnetNVTChannel.java
    > Terminable.java
    > UnixLoginHandler.java
    

    That will allow you to write a program similar to the one in the question:

    Socket s = new Socket("host.myco", 23);
    Writer w = new OutputStreamWriter(s.getOutputStream());
    UnixLoginHandler handler = new UnixLoginHandler(s);
    TelnetInputStreamConsumer is = handler.doLogin("imauser","secre3t");
    System.out.println(is.consumeInput(10000));
    is.setConsumptionOperationsTimeout(10000);
    w.write("tail MyFile.txt\r\n");w.flush();
    String output = is.consumeByCriteria(new TelnetInputStreamConsumer.ContainsStringCriterium("$ "));
    handler.doLogout();
    System.out.println("output:\n" + output);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked at several of the other regular expressions questions here and on
I have looked and tried but don't see where I can stop some being
I've looked through several other questions here and on other sites regarding this issue,
I have looked around here to see if somebody has asked this question before
I've looked at several similar questions but I didn't see any that directly applied
First off, I've looked at several other questions about optimizing sql queries, but I'm
I have looked at several other questions but I can't seem to figure any
I've looked through several of the questions here and am not quite connecting all
I've looked at several objects in the root\virtualization name space but I have not
I have looked over the Repository pattern and I recognized some ideas that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.