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

AttributeValuesRequired
useridA user id to login into server.Yes
passwordPassword to login into server.Yes
serverServer name/address.Yes
portthe port number of the remote telnet server.No
initialCRsend a cr after connecting.No
timeoutset 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

We can also specify port number to connect with the network running on different-different port numbers.

Next Topic#




Latest Courses