From a5afbd50a794a3a902ad14644cdf8b75190267e2 Mon Sep 17 00:00:00 2001 From: wakou Date: Mon, 11 Sep 2000 22:02:37 +0000 Subject: wakou git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/telnet.rb | 56 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'lib/net/telnet.rb') diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb index 9377d47888..43d80693ec 100644 --- a/lib/net/telnet.rb +++ b/lib/net/telnet.rb @@ -1,10 +1,10 @@ =begin -== SIMPLE TELNET CLIENT LIBRARY +== NAME -net/telnet.rb +net/telnet.rb - simple telnet client library -Version 1.5.0 +Version 1.6.0 Wakou Aoyama @@ -71,7 +71,7 @@ of cource, set sync=true or flush is necessary. line = host.cmd("string") line = host.cmd({"String" => "string", - "Prompt" => /[$%#>] \z/n, + "Match" => /[$%#>] \z/n, "Timeout" => 10}) @@ -79,7 +79,7 @@ of cource, set sync=true or flush is necessary. host.cmd("string"){|c| print c } host.cmd({"String" => "string", - "Prompt" => /[$%#>] \z/n, + "Match" => /[$%#>] \z/n, "Timeout" => 10}){|c| print c } of cource, set sync=true or flush is necessary. @@ -88,7 +88,17 @@ of cource, set sync=true or flush is necessary. === SEND STRING host.print("string") - # == host.write("string\n") + host.puts("string") + +Telnet#puts() adds "\n" to the last of "string". + +WARNING: Telnet#print() NOT adds "\n" to the last of "string", in the future. + +If "Telnetmode" option is true, then escape IAC code ("\xFF"). If +"Binmode" option is false, then convert "\n" to EOL(end of line) code. + +If "WILL SGA" and "DO BIN", then EOL is CR. If "WILL SGA", then EOL is +CR + NULL. If the other cases, EOL is CR + LF. === TOGGLE TELNET COMMAND INTERPRETATION @@ -109,25 +119,19 @@ of cource, set sync=true or flush is necessary. host.login("username", "password") host.login({"Name" => "username", - "Password" => "password", - "Prompt" => /[$%#>] \z/n, - "Timeout" => 10}) + "Password" => "password"}) if no password prompt: host.login("username") - host.login({"Name" => "username", - "Prompt" => /[$%#>] \z/n, - "Timeout" => 10}) + host.login({"Name" => "username"}) ==== REALTIME OUTPUT host.login("username", "password"){|c| print c } host.login({"Name" => "username", - "Password" => "password", - "Prompt" => /[$%#>] \z/n, - "Timeout" => 10}){|c| print c } + "Password" => "password"}){|c| print c } of cource, set sync=true or flush is necessary. @@ -235,10 +239,10 @@ module Net CR = "\015" LF = "\012" EOL = CR + LF - VERSION = "1.5.0" - RELEASE_DATE = "2000-06-19" - VERSION_CODE = 150 - RELEASE_CODE = 20000619 + VERSION = "1.6.0" + RELEASE_DATE = "2000-09-12" + VERSION_CODE = 160 + RELEASE_CODE = 20000912 def initialize(options) @options = options @@ -507,6 +511,10 @@ module Net end def print(string) + if $VERBOSE + $stderr.puts 'WARNING: Telnet#print("string") NOT adds "\n" to the last of "string", in the future.' + $stderr.puts ' cf. Telnet#puts().' + end string = string + "\n" string = string.gsub(/#{IAC}/no, IAC + IAC) if @options["Telnetmode"] @@ -526,6 +534,10 @@ module Net end end + def puts(string) + self.print(string) + end + def cmd(options) match = @options["Prompt"] time_out = @options["Timeout"] @@ -584,6 +596,12 @@ end == HISTORY +* Tue Sep 12 06:52:48 JST 2000 - wakou + * version 1.6.0 + * correct: document. + thanks to Kazuhiro NISHIYAMA + * add: Telnet#puts(). + * Sun Jun 18 23:31:44 JST 2000 - wakou * version 1.5.0 * change: version syntax. old: x.yz, now: x.y.z -- cgit v1.2.3