mirror of
https://github.com/apache/ant.git
synced 2025-05-18 14:04:48 +00:00
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272826 13f79535-47bb-0310-9956-ffa450edef68
141 lines
4.6 KiB
HTML
141 lines
4.6 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<meta http-equiv="Content-Language" content="en-us">
|
|
<title>Telnet Task</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h2><a name="telnet">Telnet</a></h2>
|
|
<h3>Description</h3>
|
|
Task to automate a remote telnet session. The task uses
|
|
nested <tt><read></tt> to indicate strings to wait for, and
|
|
<tt><write></tt> tags to specify text to send.
|
|
|
|
<p>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.</p>
|
|
<p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
|
|
See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
|
|
|
|
<h3>Parameters</h3>
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<th>Attribute</th>
|
|
<th>Values</th>
|
|
<th>Required</th>
|
|
</tr>
|
|
<tr>
|
|
<td>userid</td>
|
|
<td>the login id to use on the telnet server.</td>
|
|
<td>Only if password is specified</td>
|
|
</tr>
|
|
<tr>
|
|
<td>password</td>
|
|
<td>the login password to use on the telnet server.</td>
|
|
<td>Only if userid is specified</td>
|
|
</tr>
|
|
<tr>
|
|
<td>server</td>
|
|
<td>the address of the remote telnet server.</td>
|
|
<td>Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td>port</td>
|
|
<td>the port number of the remote telnet server. Defaults to port 23.</td>
|
|
<td>No</td>
|
|
</tr>
|
|
<tr>
|
|
<td>initialCR</td>
|
|
<td>send a cr after connecting ("yes"). Defaults to "no".</td>
|
|
<td>No</td>
|
|
</tr>
|
|
<tr>
|
|
<td>timeout</td>
|
|
<td>set a default timeout to wait for a response. Specified in seconds. Default is no timeout.</td>
|
|
<td>No</td>
|
|
</tr>
|
|
</table>
|
|
<h3><a name="nested">Nested Elements</a></h3>
|
|
The commands to send to the server, and responses to wait for, are
|
|
described as nested elements.
|
|
|
|
<h4>read</h4>
|
|
|
|
<p>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 <tt>string</tt>
|
|
attribute, which is an alternative to specifying the string as
|
|
a text element.
|
|
</p>
|
|
<i>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.
|
|
</i>
|
|
<h4>write</h4>
|
|
|
|
<p>describes the text to send to the server. The <tt>echo</tt> boolean
|
|
attribute controls whether the string is echoed to the local log;
|
|
this is "true" by default
|
|
</p>
|
|
<h3>Examples</h3>
|
|
A simple example of connecting to a server and running a command. This assumes
|
|
a prompt of "ogin:" for the userid, and a prompt of "assword:"
|
|
for the password.
|
|
|
|
<blockquote><pre>
|
|
<telnet userid="bob" password="badpass" server="localhost">
|
|
<read>/home/bob</read>
|
|
<write>ls</write>
|
|
<read string="/home/bob"/>
|
|
</telnet>
|
|
</pre></blockquote>
|
|
|
|
This task can be rewritten as:
|
|
<blockquote><pre>
|
|
<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>
|
|
</pre></blockquote>
|
|
|
|
A timeout can be specified at the <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.
|
|
<blockquote><pre>
|
|
<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>
|
|
</pre></blockquote>
|
|
|
|
The task can be used with other ports as well:
|
|
<blockquote><pre>
|
|
<telnet port="80" server="localhost" timeout="20">
|
|
<read/>
|
|
<write>GET / http/0.9</write>
|
|
<write/>
|
|
<read timeout="10">&lt;/HTML&gt;</read>
|
|
</telnet>
|
|
</pre></blockquote>
|
|
<p>
|
|
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.
|
|
</p>
|
|
<hr>
|
|
<p align="center">Copyright © 2000-2002 Apache Software Foundation. All rights
|
|
Reserved.</p>
|
|
|
|
</body>
|
|
</html>
|
|
|