source: release-kits/lirk3/resources/gs3-release-maker/ant/docs/manual/OptionalTasks/telnet.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 4.7 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Telnet Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="telnet">Telnet</a></h2>
12<h3>Description</h3>
13Task to automate a remote telnet session. The task uses
14nested <tt>&lt;read&gt;</tt> to indicate strings to wait for, and
15<tt>&lt;write&gt;</tt> tags to specify text to send.
16
17<p>If you do specify a userid and password, the system will
18assume a common unix prompt to wait on. This behavior can be easily over-ridden.</p>
19<p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
20See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
21
22<h3>Parameters</h3>
23<table border="1" cellpadding="2" cellspacing="0">
24 <tr>
25 <th>Attribute</th>
26 <th>Values</th>
27 <th>Required</th>
28 </tr>
29 <tr>
30 <td>userid</td>
31 <td>the login id to use on the telnet server.</td>
32 <td>Only if password is specified</td>
33 </tr>
34 <tr>
35 <td>password</td>
36 <td>the login password to use on the telnet server.</td>
37 <td>Only if userid is specified</td>
38 </tr>
39 <tr>
40 <td>server</td>
41 <td>the address of the remote telnet server.</td>
42 <td>Yes</td>
43 </tr>
44 <tr>
45 <td>port</td>
46 <td>the port number of the remote telnet server. Defaults to port 23.</td>
47 <td>No</td>
48 </tr>
49 <tr>
50 <td>initialCR</td>
51 <td>send a cr after connecting (&quot;yes&quot;). Defaults to &quot;no&quot;.</td>
52 <td>No</td>
53 </tr>
54 <tr>
55 <td>timeout</td>
56 <td>set a default timeout to wait for a response. Specified in seconds. Default is no timeout.</td>
57 <td>No</td>
58 </tr>
59</table>
60<h3><a name="nested">Nested Elements</a></h3>
61The commands to send to the server, and responses to wait for, are
62described as nested elements.
63
64<h4>read</h4>
65
66<p>declare (as a text child of this element) a string to wait for.
67The element supports the timeout attribute, which overrides any
68timeout specified for the task as a whole. It also has a <tt>string</tt>
69attribute, which is an alternative to specifying the string as
70a text element.
71</p>
72<i>Always declare an opening and closing
73<code>&lt;read&gt;</code> element to ensure that statements are not sent before
74the connection is ready, and that the connection is not broken before
75the final command has completed.
76</i>
77<h4>write</h4>
78
79<p>describes the text to send to the server. The <tt>echo</tt> boolean
80attribute controls whether the string is echoed to the local log;
81this is "true" by default
82</p>
83<h3>Examples</h3>
84A simple example of connecting to a server and running a command. This assumes
85 a prompt of &quot;ogin:&quot; for the userid, and a prompt of &quot;assword:&quot;
86 for the password.
87
88<blockquote><pre>
89&lt;telnet userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot;&gt;
90 &lt;read&gt;/home/bob&lt;/read&gt;
91 &lt;write&gt;ls&lt;/write&gt;
92 &lt;read string=&quot;/home/bob&quot;/&gt;
93&lt;/telnet&gt;
94</pre></blockquote>
95
96This task can be rewritten as:
97<blockquote><pre>
98&lt;telnet server=&quot;localhost&quot;&gt;
99 &lt;read&gt;ogin:&lt;/read&gt;
100 &lt;write&gt;bob&lt;/write&gt;
101 &lt;read&gt;assword:&lt;/read&gt;
102 &lt;write&gt;badpass&lt;/write&gt;
103 &lt;read&gt;/home/bob&lt;/read&gt;
104 &lt;write&gt;ls&lt;/write&gt;
105 &lt;read&gt;/home/bob&lt;/read&gt;
106&lt;/telnet&gt;
107</pre></blockquote>
108
109A timeout can be specified at the <code>&lt;telnet&gt;</code> level or at the <code>&lt;read&gt;</code> level.
110This will connect, issue a sleep command that is suppressed from displaying and wait
11110 seconds before quitting.
112<blockquote><pre>
113&lt;telnet userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot; timeout=&quot;20&quot;&gt;
114 &lt;read&gt;/home/bob&lt;/read&gt;
115 &lt;write echo=&quot;false&quot;&gt;sleep 15&lt;/write&gt;
116 &lt;read timeout=&quot;10&quot;&gt;/home/bob&lt;/read&gt;
117&lt;/telnet&gt;
118</pre></blockquote>
119
120The task can be used with other ports as well:
121<blockquote><pre>
122&lt;telnet port=&quot;80&quot; server=&quot;localhost&quot; timeout=&quot;20&quot;&gt;
123 &lt;read/&gt;
124 &lt;write&gt;GET / http/0.9&lt;/write&gt;
125 &lt;write/&gt;
126 &lt;read timeout=&quot;10&quot;&gt;&amp;lt;/HTML&amp;gt;&lt;/read&gt;
127&lt;/telnet&gt;
128</pre></blockquote>
129<p>
130To use this task against the WinNT telnet service, you need to configure the service to use
131classic authentication rather than NTLM negotiated authentication.
132This can be done in the Telnet Server Admin app:
133select "display/change registry settings", then "NTLM", then set the value of NTLM to 1.
134</p>
135<hr>
136<p align="center">Copyright &copy; 2000-2002,2004 The Apache Software Foundation. All rights
137Reserved.</p>
138
139</body>
140</html>
141
Note: See TracBrowser for help on using the repository browser.