You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

telnet.html 3.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="telnet">Telnet</a></h2>
  8. <h3>Description</h3>
  9. Task to automate a remote telnet session. The task uses nested &lt;read&gt; to indicate strings to wait for, and &lt;write&gt; tags to specify text to send.
  10. <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>
  11. <h3>Parameters</h3>
  12. <table border="1" cellpadding="2" cellspacing="0">
  13. <tr>
  14. <th>Attribute</th>
  15. <th>Values</th>
  16. <th>Required</th>
  17. </tr>
  18. <tr>
  19. <td>userid</td>
  20. <td>the login id to use on the telnet server.</td>
  21. <td>No</td>
  22. </tr>
  23. <tr>
  24. <td>password</td>
  25. <td>the login password to use on the telnet server.</td>
  26. <td>No</td>
  27. </tr>
  28. <tr>
  29. <td>server</td>
  30. <td>the address of the remote telnet server.</td>
  31. <td>Yes</td>
  32. </tr>
  33. <tr>
  34. <td>port</td>
  35. <td>the port number of the remote telnet server. Defaults to port 23.</td>
  36. <td>No</td>
  37. </tr>
  38. <tr>
  39. <td>initialCR</td>
  40. <td>send a cr after connecting (&quot;yes&quot;). Defaults to &quot;no&quot;.</td>
  41. <td>No</td>
  42. </tr>
  43. <tr>
  44. <td>timeout</td>
  45. <td>set a default timeout to wait for a response. Specified in seconds. Default is no timeout.</td>
  46. <td>No</td>
  47. </tr>
  48. </table>
  49. <h3>Examples</h3>
  50. A simple example of connecting to a server and running a command. This assumes a prompt of &quot;ogin:&quot; for the userid, and a prompt of &quot;assword:&quot; for the password.
  51. <blockquote><pre>
  52. &lt;telnet userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot;&gt;
  53. &lt;read&gt;/home/bob&lt;/read&gt;
  54. &lt;write&gt;ls&lt;/write&gt;
  55. &lt;read string=&quot;/home/bob&quot;/&gt;
  56. &lt;/telnet&gt;
  57. </pre></blockquote>
  58. This task can be rewritten as:
  59. <blockquote><pre>
  60. &lt;telnet server=&quot;localhost&quot;&gt;
  61. &lt;read&gt;ogin:&lt;/read&gt;
  62. &lt;write&gt;bob&lt;/write&gt;
  63. &lt;read&gt;assword:&lt;/read&gt;
  64. &lt;write&gt;badpass&lt;/write&gt;
  65. &lt;read&gt;/home/bob&lt;/read&gt;
  66. &lt;write&gt;ls&lt;/write&gt;
  67. &lt;read&gt;/home/bob&lt;/read&gt;
  68. &lt;/telnet&gt;
  69. </pre></blockquote>
  70. A timeout can be specified at the &lt;telnet&gt; level or at the &lt;read&gt; level. This will connect, issue a sleep command that is suppressed from displaying and wait 10 seconds before quitting.
  71. <blockquote><pre>
  72. &lt;telnet userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot; timeout=&quot;20&quot;&gt;
  73. &lt;read&gt;/home/bob&lt;/read&gt;
  74. &lt;write echo=&quot;false&quot;&gt;sleep 15&lt;/write&gt;
  75. &lt;read timeout=&quot;10&quot;&gt;/home/bob&lt;/read&gt;
  76. &lt;/telnet&gt;
  77. </pre></blockquote>
  78. The task can be used with other ports as well:
  79. <blockquote><pre>
  80. &lt;telnet port=&quot;80&quot; server=&quot;localhost&quot; timeout=&quot;20&quot;&gt;
  81. &lt;read/&gt;
  82. &lt;write&gt;GET / http/0.9&lt;/write&gt;
  83. &lt;write/&gt;
  84. &lt;read timeout=&quot;10&quot;&gt;&amp;lt;/HTML&amp;gt;&lt;/read&gt;
  85. &lt;/telnet&gt;
  86. </pre></blockquote>
  87. <hr>
  88. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  89. Reserved.</p>
  90. </body>
  91. </html>