Javatpoint Logo
Javatpoint Logo

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

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

Next Topic#




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA