#4 TelnetWrapper in jta25-src.jar

open
nobody
None
5
2014-08-19
2004-04-29
Steve
No

Hello,

I am trying to use the TelnetWrapper to use the code as
embedded code. I have added a main into a new class
TestTelnetWrapper as per your comments e.g:

public class TestTelnetWrapper {

public TestTelnetWrapper (){}

public static void main ( String args{}) {

TelnetWrapper telnet = new TelnetWrapper();
try {
telnet.connect("127.0.0.1", 23);
telnet.login("user", "password");

// never gets here

telnet.setPrompt("user@host";);
telnet.waitfor("Terminal type?");
telnet.send("dumb");
System.out.println(telnet.send("ls -l"));
} catch(java.io.IOException e) {
e.printStackTrace();
}
}//end main
}

The code seems to connect ok, but it then seems to be
stuck waiting for the "login:" back from the telnet
session. I've added some debug & it gets into the
waitfor method in Wrapper but never gets very much
back from the Telnet read method.

What works:
1) I can run it quite happily using the Main class in
de.mud.jta (i.e. bringing up the Applet)
2) I can telnet by hand ok at the command line.

Is there anything else you need to do to run it as an
application rather than as the Applet? i.e. properties
files, plugins??

Any ideas?

Steve
p.s. I'm running on a linux box

Discussion

  • Logged In: YES
    user_id=48092

    so does the remote host send "login:" and "password:" strings like
    the wrapper expects?

     
  • Steve
    Steve
    2004-05-03

    Logged In: YES
    user_id=1031486

    Yes - the host will send back "login:" and "Password:" if you
    telnet in by hand or use your Applet version, but with the
    Telnet Wrapper version, the read(b1) in the waitfor method
    returns n = -1, 1, 0, -1, 0, -1, 1, 0, -1 .. i.e. nothing
    meaningful so the login is not found.

    I have added some more debug prints & the resulting output
    is as follows:

    TestTelnetWrapper.main: entered
    ** The Java(tm) Telnet Application
    ** Version 2.5 for Java 2
    ** Copyright (c) 1996-2003 Matthias L. Jugel, Marcus
    Meissner
    ** Build: 20031210-1040
    jta: loading plugin 'Status'
    jta: loading plugin 'Socket'
    jta: loading plugin 'Telnet'
    jta: loading plugin 'Terminal'
    colorSet: /home/user/telnetStuff/jta25/de/mud/terminal/colorS
    et.conf
    Terminal: cannot find
    colorSet: /home/user/telnetStuff/jta25/de/mud/terminal/colorS
    et.conf
    Terminal: resource access failed:
    java.lang.NullPointerException
    Terminal: URL access failed: java.net.MalformedURLException:
    no
    protocol: /home/user/telnetStuff/jta25/de/mud/terminal/colorS
    et.conf
    Terminal: cannot find
    keyCodes: /home/user/telnetStuff/jta25/de/mud/terminal/keyC
    odes.conf
    Terminal: resource access failed:
    java.lang.NullPointerException
    Terminal: URL access failed: java.net.MalformedURLException:
    no
    protocol: /home/user/telnetStuff/jta25/de/mud/terminal/keyCo
    des.conf
    byte: -1 byte: -3 DO byte: 24 TTYPE
    byte: -1 byte: -3 DO byte: 32 <UNKNOWN,32>
    byte: -1 TelnetWrapper.connect: entered
    Wrapper.connect: host = 127.0.0.1, port = 23
    Wrapper.connect: exit
    TelnetWrapper.connect: exit
    Wrapper.login: entered with "user", and "passwd"
    Wrapper.login: waiting for "login:" text
    Wrapper.waitfor: entered with "login:"
    Wrapper.waitfor: string to search for = "login:"
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235

    byte: -3 DO byte: 35 <UNKNOWN,35>
    byte: -1 byte: -3 DO byte: 39 <UNKNOWN,39>
    byte: -1 byte: -6 SB byte: 24 24
    byte: 1 1

    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0byte: -1 -1
    byte: -16 -16
    TelnetIO.handle_sb(24)
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1
    Telnet.read: n2 = 1
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: returning 0
    Telnet.read: n3 = 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n3 = -1
    Wrapper.waitfor: n is 0
    TelnetProtocolHandler.negotiate: entered with 1 bytes i.e.
    [B@18f6235
    TelnetProtocolHandler.negotiate: buffer is empty, returning -1
    Telnet.read: n1 = -1

     
  • Alison Winters
    Alison Winters
    2004-10-18

    Logged In: YES
    user_id=1141853

    As far as i know, you have to run it via de.mud.jta.Main
    because that's what puts together the whole Socket
    connection and everything. I'd suggest making a custom
    Plugin that attaches to the plugin bus (via the config file) and
    then give it an OnlineStatusListener so when the socket is
    opened you can set the telnet login details.

     
  • Logged In: NO

    I am also facing the same problem.
    Can any one help me in this regard.

    srinivasan