Home » Apache Ant Telnet Task

Apache Ant Telnet Task

by Online Tutorials Library

Apache Ant Telnet Task

Ant Telnet task is used to provide bidirectional text oriented communication facility. It is a network protocol. By default Apache Ant does not support it. So, we need to include a external JAR commons-net.jar file into classpath.

This task is mainly used to automate telnet session xml file.

The <telnet> element supports nested elements <read> and <write>to perform read/write operations respectively.

Apache Ant Telnet Task Attributes

Attribute Values Required
userid A user id to login into server. Yes
password Password to login into server. Yes
server Server name/address. Yes
port the port number of the remote telnet server. No
initialCR send a cr after connecting. No
timeout set a default timeout to wait for a response. No

Let’s see some example to understand the telnet task.

Apache Ant Telnet Task Example

The above example is a simple telnet connection program which connect to localhost by mapping provided userid and password.

Time Out

During connection, we can also set connection timeout period.

Specify Port Number

You may also like