If you do specify a userid and password, the system will assume a common unix prompt to wait on. This behavior can be easily over-ridden.
Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information.
Attribute | Values | Required |
---|---|---|
userid | the login id to use on the telnet server. | Only if password is specified |
password | the login password to use on the telnet server. | Only if userid is specified |
server | the address of the remote telnet server. | Yes |
port | the port number of the remote telnet server. Defaults to port 23. | No |
initialCR | send a cr after connecting ("yes"). Defaults to "no". | No |
timeout | set a default timeout to wait for a response. Specified in seconds. Default is no timeout. | No |
declare (as a text child of this element) a string to wait for. The element supports the timeout attribute, which overrides any timeout specified for the task as a whole. It also has a string attribute, which is an alternative to specifying the string as a text element.
Always declare an opening and closing<read>
element to ensure that statements are not sent before
the connection is ready, and that the connection is not broken before
the final command has completed.
describes the text to send to the server. The echo boolean attribute controls whether the string is echoed to the local log; this is "true" by default
This task can be rewritten as:<telnet userid="bob" password="badpass" server="localhost"> <read>/home/bob</read> <write>ls</write> <read string="/home/bob"/> </telnet>
A timeout can be specified at the<telnet server="localhost"> <read>ogin:</read> <write>bob</write> <read>assword:</read> <write>badpass</write> <read>/home/bob</read> <write>ls</write> <read>/home/bob</read> </telnet>
<telnet>
level or at the <read>
level.
This will connect, issue a sleep command that is suppressed from displaying and wait
10 seconds before quitting.
The task can be used with other ports as well:<telnet userid="bob" password="badpass" server="localhost" timeout="20"> <read>/home/bob</read> <write echo="false">sleep 15</write> <read timeout="10">/home/bob</read> </telnet>
<telnet port="80" server="localhost" timeout="20"> <read/> <write>GET / http/0.9</write> <write/> <read timeout="10"></HTML></read> </telnet>
To use this task against the WinNT telnet service, you need to configure the service to use classic authentication rather than NTLM negotiated authentication. This can be done in the Telnet Server Admin app: select "display/change registry settings", then "NTLM", then set the value of NTLM to 1.