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 4.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Telnet</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
  10. nested &lt;read&gt; to indicate strings to wait for, and
  11. &lt;write&gt; tags to specify text to send.
  12. <p>If you do specify a userid and password, the system will
  13. assume a common unix prompt to wait on. This behavior can be easily over-ridden.</p>
  14. <h3>Parameters</h3>
  15. <table border="1" cellpadding="2" cellspacing="0">
  16. <tr>
  17. <th>Attribute</th>
  18. <th>Values</th>
  19. <th>Required</th>
  20. </tr>
  21. <tr>
  22. <td>userid</td>
  23. <td>the login id to use on the telnet server.</td>
  24. <td>Only if password is specified</td>
  25. </tr>
  26. <tr>
  27. <td>password</td>
  28. <td>the login password to use on the telnet server.</td>
  29. <td>Only if userid is specified</td>
  30. </tr>
  31. <tr>
  32. <td>server</td>
  33. <td>the address of the remote telnet server.</td>
  34. <td>Yes</td>
  35. </tr>
  36. <tr>
  37. <td>port</td>
  38. <td>the port number of the remote telnet server. Defaults to port 23.</td>
  39. <td>No</td>
  40. </tr>
  41. <tr>
  42. <td>initialCR</td>
  43. <td>send a cr after connecting (&quot;yes&quot;). Defaults to &quot;no&quot;.</td>
  44. <td>No</td>
  45. </tr>
  46. <tr>
  47. <td>timeout</td>
  48. <td>set a default timeout to wait for a response. Specified in seconds. Default is no timeout.</td>
  49. <td>No</td>
  50. </tr>
  51. </table>
  52. <h3><a name="nested">Nested Elements</a></h3>
  53. The commands to send to the server, and responses to wait for, are
  54. described as nested elements.
  55. <h4>read</h4>
  56. <p>declare (as a text child of this element) a string to wait for.
  57. The element supports the timeout attribute, which overrides any
  58. timeout specified for the task as a whole. It also has a <tt>string<tt>
  59. attribute, which is an alternative to specifying the string as
  60. a text element.
  61. </p>
  62. <i>Always declare an opening and closing
  63. &lt;read&gt; element to ensure that statements are not sent before
  64. the connection is ready, and that the connection is not broken before
  65. the final command has completed.
  66. </i>
  67. <h4>write</h4>
  68. <p>describes the text to send to the server. The <tt>echo</tt> boolean
  69. attribute controls whether the string is echoed to the local log;
  70. this is "true" by default
  71. </p>
  72. <h3>Examples</h3>
  73. A simple example of connecting to a server and running a command. This assumes
  74. a prompt of &quot;ogin:&quot; for the userid, and a prompt of &quot;assword:&quot;
  75. for the password.
  76. <blockquote><pre>
  77. &lt;telnet userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot;&gt;
  78. &lt;read&gt;/home/bob&lt;/read&gt;
  79. &lt;write&gt;ls&lt;/write&gt;
  80. &lt;read string=&quot;/home/bob&quot;/&gt;
  81. &lt;/telnet&gt;
  82. </pre></blockquote>
  83. This task can be rewritten as:
  84. <blockquote><pre>
  85. &lt;telnet server=&quot;localhost&quot;&gt;
  86. &lt;read&gt;ogin:&lt;/read&gt;
  87. &lt;write&gt;bob&lt;/write&gt;
  88. &lt;read&gt;assword:&lt;/read&gt;
  89. &lt;write&gt;badpass&lt;/write&gt;
  90. &lt;read&gt;/home/bob&lt;/read&gt;
  91. &lt;write&gt;ls&lt;/write&gt;
  92. &lt;read&gt;/home/bob&lt;/read&gt;
  93. &lt;/telnet&gt;
  94. </pre></blockquote>
  95. 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.
  96. <blockquote><pre>
  97. &lt;telnet userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot; timeout=&quot;20&quot;&gt;
  98. &lt;read&gt;/home/bob&lt;/read&gt;
  99. &lt;write echo=&quot;false&quot;&gt;sleep 15&lt;/write&gt;
  100. &lt;read timeout=&quot;10&quot;&gt;/home/bob&lt;/read&gt;
  101. &lt;/telnet&gt;
  102. </pre></blockquote>
  103. The task can be used with other ports as well:
  104. <blockquote><pre>
  105. &lt;telnet port=&quot;80&quot; server=&quot;localhost&quot; timeout=&quot;20&quot;&gt;
  106. &lt;read/&gt;
  107. &lt;write&gt;GET / http/0.9&lt;/write&gt;
  108. &lt;write/&gt;
  109. &lt;read timeout=&quot;10&quot;&gt;&amp;lt;/HTML&amp;gt;&lt;/read&gt;
  110. &lt;/telnet&gt;
  111. </pre></blockquote>
  112. <hr>
  113. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  114. Reserved.</p>
  115. </body>
  116. </html>