public class TelnetSession extends Object implements CliSession
TelnetSession c = new TelnetSession("127.0.0.1", 23);
Constructor and Description |
---|
TelnetSession(NedWorker worker)
Constructor for Telnet session object.
|
TelnetSession(NedWorker worker,
int readTimeout,
NedTracer tracer,
NedConnectionBase conn)
Constructor with an extra argument for a readTimeout timer.
|
TelnetSession(NedWorker worker,
NedTracer tracer,
NedConnectionBase conn)
Constructor for Telnet session object.
|
TelnetSession(NedWorker worker,
String username,
int readTimeout,
NedTracer tracer,
NedConnectionBase conn)
Constructor with extra user name argument.
|
TelnetSession(String host,
int port)
Deprecated.
|
TelnetSession(String host,
int port,
int readTimeout,
NedTracer tracer,
NedConnectionBase conn)
Deprecated.
|
TelnetSession(String host,
int port,
NedTracer tracer,
NedConnectionBase conn)
Deprecated.
|
TelnetSession(String host,
int port,
String username,
int readTimeout,
NedTracer tracer,
NedConnectionBase conn)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
expect(Pattern p) |
NedExpectResult |
expect(Pattern[] p) |
NedExpectResult |
expect(Pattern[] p,
boolean include,
int timeout) |
NedExpectResult |
expect(Pattern[] p,
boolean include,
int timeout,
boolean full) |
NedExpectResult |
expect(Pattern[] p,
boolean include,
int timeout,
boolean full,
NedWorker worker) |
NedExpectResult |
expect(Pattern[] p,
boolean include,
int timeout,
NedWorker worker) |
NedExpectResult |
expect(Pattern[] p,
NedWorker worker) |
String |
expect(Pattern p,
boolean include,
int timeout) |
String |
expect(Pattern p,
boolean include,
int timeout,
NedWorker worker) |
String |
expect(Pattern p,
NedWorker worker) |
String |
expect(String Str)
Read from socket until Pattern is encountered.
|
NedExpectResult |
expect(String[] Str) |
NedExpectResult |
expect(String[] Str,
boolean include,
int timeout) |
NedExpectResult |
expect(String[] Str,
boolean include,
int timeout,
NedWorker worker) |
NedExpectResult |
expect(String[] Str,
NedWorker worker) |
String |
expect(String str,
boolean include,
boolean full,
int timeout)
Read from socket until Pattern is encountered.
|
String |
expect(String str,
boolean include,
boolean full,
int timeout,
NedWorker worker) |
String |
expect(String Str,
boolean Include,
int timeout)
Read from socket until Pattern is encountered.
|
String |
expect(String Str,
boolean Include,
int timeout,
NedWorker worker) |
String |
expect(String Str,
int timeout)
Read from socket until Pattern is encountered.
|
String |
expect(String Str,
int timeout,
NedWorker worker) |
String |
expect(String Str,
NedWorker worker) |
void |
flush()
Signals that the final chunk of data has be printed to the output
transport stream.
|
Socket |
getSocket()
Needed by users that need to monitor a socket for EOF .
|
void |
print(String s)
Prints text to the output stream.
|
void |
println(String s)
Print text to the output stream.
|
boolean |
ready()
Tell whether this transport is ready to be read.
|
boolean |
ready(int timeout) |
boolean |
serverSideClosed()
given a live session, check if the server side has
closed it's end of the socket.
|
void |
setScreenSize(int width,
int length) |
void |
setTracer(NedTracer tracer) |
void |
write(String s) |
public TelnetSession(NedWorker worker) throws IOException
worker
- current NedWorker objectIOException
@Deprecated public TelnetSession(String host, int port) throws IOException
IOException
public TelnetSession(NedWorker worker, NedTracer tracer, NedConnectionBase conn) throws IOException
worker
- current NedWorker objecttracer
- Ned tracerconn
- NedConnection objectIOException
@Deprecated public TelnetSession(String host, int port, NedTracer tracer, NedConnectionBase conn) throws IOException
IOException
public TelnetSession(NedWorker worker, int readTimeout, NedTracer tracer, NedConnectionBase conn) throws IOException
worker
- current NedWorker objectreadTimeout
- timeout in millisecondstracer
- Ned tracerconn
- NedConnection objectIOException
@Deprecated public TelnetSession(String host, int port, int readTimeout, NedTracer tracer, NedConnectionBase conn) throws IOException
host
- port
- readTimeout
- Time to wait for read. (in milliseconds)tracer
- conn
- IOException
public TelnetSession(NedWorker worker, String username, int readTimeout, NedTracer tracer, NedConnectionBase conn) throws IOException
worker
- current NedWorker objectusername
- readTimeout
- timeout in millisecondstracer
- Ned tracerconn
- NedConnection objectIOException
@Deprecated public TelnetSession(String host, int port, String username, int readTimeout, NedTracer tracer, NedConnectionBase conn) throws IOException
host
- port
- username
- readTimeout
- tracer
- conn
- IOException
public void setScreenSize(int width, int length) throws IOException
IOException
public String expect(String Str, boolean Include, int timeout) throws IOException
expect
in interface CliSession
Str
- is a regular expression pattern which is match against
each line read.Include
- controls if the pattern should be include
in the returned string or not.IOException
public String expect(Pattern p, boolean include, int timeout) throws IOException
IOException
public String expect(String Str, boolean Include, int timeout, NedWorker worker) throws IOException
IOException
public String expect(Pattern p, boolean include, int timeout, NedWorker worker) throws IOException
IOException
public String expect(String Str) throws IOException
expect
in interface CliSession
Str
- is a regular expression pattern which is match against
each line read.IOException
public String expect(Pattern p) throws SSHSessionException, IOException
expect
in interface CliSession
SSHSessionException
IOException
public String expect(String Str, NedWorker worker) throws IOException
expect
in interface CliSession
IOException
public String expect(Pattern p, NedWorker worker) throws SSHSessionException, IOException
expect
in interface CliSession
SSHSessionException
IOException
public String expect(String Str, int timeout) throws IOException
expect
in interface CliSession
Str
- is a regular expression pattern which is match against
each line read.timeout
- indicates the read timeoutIOException
public NedExpectResult expect(String[] Str) throws IOException
expect
in interface CliSession
IOException
public NedExpectResult expect(Pattern[] p) throws SSHSessionException, IOException
expect
in interface CliSession
SSHSessionException
IOException
public NedExpectResult expect(String[] Str, boolean include, int timeout) throws IOException
expect
in interface CliSession
IOException
public NedExpectResult expect(Pattern[] p, boolean include, int timeout) throws IOException
expect
in interface CliSession
IOException
public String expect(String Str, int timeout, NedWorker worker) throws IOException
expect
in interface CliSession
IOException
public NedExpectResult expect(String[] Str, NedWorker worker) throws IOException
expect
in interface CliSession
IOException
public NedExpectResult expect(Pattern[] p, NedWorker worker) throws SSHSessionException, IOException
expect
in interface CliSession
SSHSessionException
IOException
public NedExpectResult expect(String[] Str, boolean include, int timeout, NedWorker worker) throws IOException
expect
in interface CliSession
IOException
public NedExpectResult expect(Pattern[] p, boolean include, int timeout, NedWorker worker) throws IOException
expect
in interface CliSession
IOException
public NedExpectResult expect(Pattern[] p, boolean include, int timeout, boolean full) throws IOException
IOException
public NedExpectResult expect(Pattern[] p, boolean include, int timeout, boolean full, NedWorker worker) throws IOException
IOException
public String expect(String str, boolean include, boolean full, int timeout) throws IOException
expect
in interface CliSession
str
- is a regular expression pattern which is match against
each line read.include
- controls if the pattern should be include
in the returned string or not.full
- controls if the pattern should be matched against
the entire line, or if a positive match is accepted whenever the
pattern matches any substring on a line.IOException
public String expect(String str, boolean include, boolean full, int timeout, NedWorker worker) throws IOException
expect
in interface CliSession
IOException
public void close()
close
in interface CliSession
public void write(String s) throws IOException
IOException
public void print(String s) throws IOException
print
in interface CliSession
s
- Text to send to the stream.IOException
public void println(String s) throws IOException
println
in interface CliSession
s
- Text to send to the stream.IOException
public void flush() throws IOException
flush
in interface CliSession
IOException
public Socket getSocket()
public boolean ready() throws IOException
IOException
public boolean ready(int timeout) throws IOException
IOException
public boolean serverSideClosed()
serverSideClosed
in interface CliSession
public void setTracer(NedTracer tracer)
setTracer
in interface CliSession