зеркало из https://github.com/github/ruby.git
expand tabs: lib/cgi.rb, lib/net/telnet.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7894825282
Коммит
cc05dcd5fe
816
lib/cgi.rb
816
lib/cgi.rb
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -12,20 +12,20 @@ Wakou Aoyama <wakou@fsinet.or.jp>
|
||||||
|
|
||||||
=== MAKE NEW TELNET OBJECT
|
=== MAKE NEW TELNET OBJECT
|
||||||
|
|
||||||
host = Net::Telnet::new({
|
host = Net::Telnet::new({
|
||||||
"Binmode" => false, # default: false
|
"Binmode" => false, # default: false
|
||||||
"Host" => "localhost", # default: "localhost"
|
"Host" => "localhost", # default: "localhost"
|
||||||
"Output_log" => "output_log", # default: nil (no output)
|
"Output_log" => "output_log", # default: nil (no output)
|
||||||
"Dump_log" => "dump_log", # default: nil (no output)
|
"Dump_log" => "dump_log", # default: nil (no output)
|
||||||
"Port" => 23, # default: 23
|
"Port" => 23, # default: 23
|
||||||
"Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
|
"Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
|
||||||
"Telnetmode" => true, # default: true
|
"Telnetmode" => true, # default: true
|
||||||
"Timeout" => 10, # default: 10
|
"Timeout" => 10, # default: 10
|
||||||
# if ignore timeout then set "Timeout" to false.
|
# if ignore timeout then set "Timeout" to false.
|
||||||
"Waittime" => 0, # default: 0
|
"Waittime" => 0, # default: 0
|
||||||
"Proxy" => proxy # default: nil
|
"Proxy" => proxy # default: nil
|
||||||
# proxy is Net::Telnet or IO object
|
# proxy is Net::Telnet or IO object
|
||||||
})
|
})
|
||||||
|
|
||||||
Telnet object has socket class methods.
|
Telnet object has socket class methods.
|
||||||
|
|
||||||
|
@ -36,98 +36,98 @@ the network or the host is very heavy, the value is enlarged.
|
||||||
|
|
||||||
=== STATUS OUTPUT
|
=== STATUS OUTPUT
|
||||||
|
|
||||||
host = Net::Telnet::new({"Host" => "localhost"}){|c| print c }
|
host = Net::Telnet::new({"Host" => "localhost"}){|c| print c }
|
||||||
|
|
||||||
connection status output.
|
connection status output.
|
||||||
|
|
||||||
example
|
example
|
||||||
|
|
||||||
Trying localhost...
|
Trying localhost...
|
||||||
Connected to localhost.
|
Connected to localhost.
|
||||||
|
|
||||||
|
|
||||||
=== WAIT FOR MATCH
|
=== WAIT FOR MATCH
|
||||||
|
|
||||||
line = host.waitfor(/match/)
|
line = host.waitfor(/match/)
|
||||||
line = host.waitfor({"Match" => /match/,
|
line = host.waitfor({"Match" => /match/,
|
||||||
"String" => "string",
|
"String" => "string",
|
||||||
"Timeout" => secs})
|
"Timeout" => secs})
|
||||||
# if ignore timeout then set "Timeout" to false.
|
# if ignore timeout then set "Timeout" to false.
|
||||||
|
|
||||||
if set "String" option, then Match == Regexp.new(quote("string"))
|
if set "String" option, then Match == Regexp.new(quote("string"))
|
||||||
|
|
||||||
|
|
||||||
==== REALTIME OUTPUT
|
==== REALTIME OUTPUT
|
||||||
|
|
||||||
host.waitfor(/match/){|c| print c }
|
host.waitfor(/match/){|c| print c }
|
||||||
host.waitfor({"Match" => /match/,
|
host.waitfor({"Match" => /match/,
|
||||||
"String" => "string",
|
"String" => "string",
|
||||||
"Timeout" => secs}){|c| print c}
|
"Timeout" => secs}){|c| print c}
|
||||||
|
|
||||||
of cource, set sync=true or flush is necessary.
|
of cource, set sync=true or flush is necessary.
|
||||||
|
|
||||||
|
|
||||||
=== SEND STRING AND WAIT PROMPT
|
=== SEND STRING AND WAIT PROMPT
|
||||||
|
|
||||||
line = host.cmd("string")
|
line = host.cmd("string")
|
||||||
line = host.cmd({"String" => "string",
|
line = host.cmd({"String" => "string",
|
||||||
"Prompt" => /[$%#>] \z/n,
|
"Prompt" => /[$%#>] \z/n,
|
||||||
"Timeout" => 10})
|
"Timeout" => 10})
|
||||||
|
|
||||||
|
|
||||||
==== REALTIME OUTPUT
|
==== REALTIME OUTPUT
|
||||||
|
|
||||||
host.cmd("string"){|c| print c }
|
host.cmd("string"){|c| print c }
|
||||||
host.cmd({"String" => "string",
|
host.cmd({"String" => "string",
|
||||||
"Prompt" => /[$%#>] \z/n,
|
"Prompt" => /[$%#>] \z/n,
|
||||||
"Timeout" => 10}){|c| print c }
|
"Timeout" => 10}){|c| print c }
|
||||||
|
|
||||||
of cource, set sync=true or flush is necessary.
|
of cource, set sync=true or flush is necessary.
|
||||||
|
|
||||||
|
|
||||||
=== SEND STRING
|
=== SEND STRING
|
||||||
|
|
||||||
host.print("string")
|
host.print("string")
|
||||||
# == host.write("string\n")
|
# == host.write("string\n")
|
||||||
|
|
||||||
|
|
||||||
=== TOGGLE TELNET COMMAND INTERPRETATION
|
=== TOGGLE TELNET COMMAND INTERPRETATION
|
||||||
|
|
||||||
host.telnetmode # return the current status (true or false)
|
host.telnetmode # return the current status (true or false)
|
||||||
host.telnetmode = true # do telnet command interpretation (default)
|
host.telnetmode = true # do telnet command interpretation (default)
|
||||||
host.telnetmode = false # don't telnet command interpretation
|
host.telnetmode = false # don't telnet command interpretation
|
||||||
|
|
||||||
|
|
||||||
=== TOGGLE NEWLINE TRANSLATION
|
=== TOGGLE NEWLINE TRANSLATION
|
||||||
|
|
||||||
host.binmode # return the current status (true or false)
|
host.binmode # return the current status (true or false)
|
||||||
host.binmode = true # no translate newline
|
host.binmode = true # no translate newline
|
||||||
host.binmode = false # translate newline (default)
|
host.binmode = false # translate newline (default)
|
||||||
|
|
||||||
|
|
||||||
=== LOGIN
|
=== LOGIN
|
||||||
|
|
||||||
host.login("username", "password")
|
host.login("username", "password")
|
||||||
host.login({"Name" => "username",
|
host.login({"Name" => "username",
|
||||||
"Password" => "password",
|
"Password" => "password",
|
||||||
"Prompt" => /[$%#>] \z/n,
|
"Prompt" => /[$%#>] \z/n,
|
||||||
"Timeout" => 10})
|
"Timeout" => 10})
|
||||||
|
|
||||||
if no password prompt.
|
if no password prompt.
|
||||||
|
|
||||||
host.login("username")
|
host.login("username")
|
||||||
host.login({"Name" => "username",
|
host.login({"Name" => "username",
|
||||||
"Prompt" => /[$%#>] \z/n,
|
"Prompt" => /[$%#>] \z/n,
|
||||||
"Timeout" => 10})
|
"Timeout" => 10})
|
||||||
|
|
||||||
|
|
||||||
==== REALTIME OUTPUT
|
==== REALTIME OUTPUT
|
||||||
|
|
||||||
host.login("username", "password"){|c| print c }
|
host.login("username", "password"){|c| print c }
|
||||||
host.login({"Name" => "username",
|
host.login({"Name" => "username",
|
||||||
"Password" => "password",
|
"Password" => "password",
|
||||||
"Prompt" => /[$%#>] \z/n,
|
"Prompt" => /[$%#>] \z/n,
|
||||||
"Timeout" => 10}){|c| print c }
|
"Timeout" => 10}){|c| print c }
|
||||||
|
|
||||||
of cource, set sync=true or flush is necessary.
|
of cource, set sync=true or flush is necessary.
|
||||||
|
|
||||||
|
@ -136,23 +136,23 @@ of cource, set sync=true or flush is necessary.
|
||||||
|
|
||||||
=== LOGIN AND SEND COMMAND
|
=== LOGIN AND SEND COMMAND
|
||||||
|
|
||||||
localhost = Net::Telnet::new({"Host" => "localhost",
|
localhost = Net::Telnet::new({"Host" => "localhost",
|
||||||
"Timeout" => 10,
|
"Timeout" => 10,
|
||||||
"Prompt" => /[$%#>] \z/n})
|
"Prompt" => /[$%#>] \z/n})
|
||||||
localhost.login("username", "password"){|c| print c }
|
localhost.login("username", "password"){|c| print c }
|
||||||
localhost.cmd("command"){|c| print c }
|
localhost.cmd("command"){|c| print c }
|
||||||
localhost.close
|
localhost.close
|
||||||
|
|
||||||
|
|
||||||
=== CHECKS A POP SERVER TO SEE IF YOU HAVE MAIL
|
=== CHECKS A POP SERVER TO SEE IF YOU HAVE MAIL
|
||||||
|
|
||||||
pop = Net::Telnet::new({"Host" => "your_destination_host_here",
|
pop = Net::Telnet::new({"Host" => "your_destination_host_here",
|
||||||
"Port" => 110,
|
"Port" => 110,
|
||||||
"Telnetmode" => false,
|
"Telnetmode" => false,
|
||||||
"Prompt" => /^\+OK/n})
|
"Prompt" => /^\+OK/n})
|
||||||
pop.cmd("user " + "your_username_here"){|c| print c}
|
pop.cmd("user " + "your_username_here"){|c| print c}
|
||||||
pop.cmd("pass " + "your_password_here"){|c| print c}
|
pop.cmd("pass " + "your_password_here"){|c| print c}
|
||||||
pop.cmd("list"){|c| print c}
|
pop.cmd("list"){|c| print c}
|
||||||
|
|
||||||
|
|
||||||
== HISTORY
|
== HISTORY
|
||||||
|
@ -224,8 +224,8 @@ of cource, set sync=true or flush is necessary.
|
||||||
1999/09/14 23:09:05
|
1999/09/14 23:09:05
|
||||||
|
|
||||||
- change prompt check order.
|
- change prompt check order.
|
||||||
not IO::select([@sock], nil, nil, waittime) and prompt === line
|
not IO::select([@sock], nil, nil, waittime) and prompt === line
|
||||||
--> prompt === line and not IO::select([@sock], nil, nil, waittime)
|
--> prompt === line and not IO::select([@sock], nil, nil, waittime)
|
||||||
|
|
||||||
=== Version 0.24
|
=== Version 0.24
|
||||||
|
|
||||||
|
@ -239,8 +239,8 @@ if ommit password, then not require password prompt.
|
||||||
1999/08/10 05:20:21
|
1999/08/10 05:20:21
|
||||||
|
|
||||||
- STATUS OUTPUT sample code typo. thanks to Tadayoshi Funaba <tadf@kt.rim.or.jp>
|
- STATUS OUTPUT sample code typo. thanks to Tadayoshi Funaba <tadf@kt.rim.or.jp>
|
||||||
host = Telnet.new({"Hosh" => "localhost"){|c| print c }
|
host = Telnet.new({"Hosh" => "localhost"){|c| print c }
|
||||||
--> host = Telnet.new({"Host" => "localhost"){|c| print c }
|
--> host = Telnet.new({"Host" => "localhost"){|c| print c }
|
||||||
|
|
||||||
=== Version 0.231
|
=== Version 0.231
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче