晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/alt/ruby18/share/ri/1.8/system/Net/Telnet/ |
| Current File : //opt/alt/ruby18/share/ri/1.8/system/Net/Telnet/cdesc-Telnet.yaml |
--- !ruby/object:RI::ClassDescription
attributes:
- !ruby/object:RI::Attribute
comment:
- !ruby/struct:SM::Flow::P
body: The socket the Telnet object is using. Note that this object becomes a delegate of the Telnet object, so normally you invoke its methods directly on the Telnet object.
name: sock
rw: R
class_methods:
- !ruby/object:RI::MethodSummary
name: new
comment:
- !ruby/struct:SM::Flow::H
level: 2
text: Net::Telnet
- !ruby/struct:SM::Flow::P
body: Provides telnet client functionality.
- !ruby/struct:SM::Flow::P
body: This class also has, through delegation, all the methods of a socket object (by default, a <tt>TCPSocket</tt>, but can be set by the <tt>Proxy</tt> option to <tt>new()</tt>). This provides methods such as <tt>close()</tt> to end the session and <tt>sysread()</tt> to read data directly from the host, instead of via the <tt>waitfor()</tt> mechanism. Note that if you do use <tt>sysread()</tt> directly when in telnet mode, you should probably pass the output through <tt>preprocess()</tt> to extract telnet command sequences.
- !ruby/struct:SM::Flow::H
level: 2
text: Overview
- !ruby/struct:SM::Flow::P
body: "The telnet protocol allows a client to login remotely to a user account on a server and execute commands via a shell. The equivalent is done by creating a Net::Telnet class with the <tt>Host</tt> option set to your host, calling #login() with your user and password, issuing one or more #cmd() calls, and then calling #close() to end the session. The #waitfor(), #print(), #puts(), and #write() methods, which #cmd() is implemented on top of, are only needed if you are doing something more complicated."
- !ruby/struct:SM::Flow::P
body: "A Net::Telnet object can also be used to connect to non-telnet services, such as SMTP or HTTP. In this case, you normally want to provide the <tt>Port</tt> option to specify the port to connect to, and set the <tt>Telnetmode</tt> option to false to prevent the client from attempting to interpret telnet command sequences. Generally, #login() will not work with other protocols, and you have to handle authentication yourself."
- !ruby/struct:SM::Flow::P
body: "For some protocols, it will be possible to specify the <tt>Prompt</tt> option once when you create the Telnet object and use #cmd() calls; for others, you will have to specify the response sequence to look for as the Match option to every #cmd() call, or call #puts() and #waitfor() directly; for yet others, you will have to use #sysread() instead of #waitfor() and parse server responses yourself."
- !ruby/struct:SM::Flow::P
body: It is worth noting that when you create a new Net::Telnet object, you can supply a proxy IO channel via the Proxy option. This can be used to attach the Telnet object to other Telnet objects, to already open sockets, or to any read-write IO object. This can be useful, for instance, for setting up a test fixture for unit testing.
- !ruby/struct:SM::Flow::H
level: 2
text: Examples
- !ruby/struct:SM::Flow::H
level: 3
text: Log in and send a command, echoing all output to stdout
- !ruby/struct:SM::Flow::VERB
body: " localhost = Net::Telnet::new("Host" => "localhost",\n "Timeout" => 10,\n "Prompt" => /[$%#>] \\z/n)\n localhost.login("username", "password") { |c| print c }\n localhost.cmd("command") { |c| print c }\n localhost.close\n"
- !ruby/struct:SM::Flow::H
level: 3
text: Check a POP server to see if you have mail
- !ruby/struct:SM::Flow::VERB
body: " pop = Net::Telnet::new("Host" => "your_destination_host_here",\n "Port" => 110,\n "Telnetmode" => false,\n "Prompt" => /^+OK/n)\n pop.cmd("user " + "your_username_here") { |c| print c }\n pop.cmd("pass " + "your_password_here") { |c| print c }\n pop.cmd("list") { |c| print c }\n"
- !ruby/struct:SM::Flow::H
level: 2
text: References
- !ruby/struct:SM::Flow::P
body: There are a large number of RFCs relevant to the Telnet protocol. RFCs 854-861 define the base protocol. For a complete listing of relevant RFCs, see http://www.omnifarious.org/~hopper/technical/telnet-rfc.html
constants: []
full_name: Net::Telnet
includes: []
instance_methods:
- !ruby/object:RI::MethodSummary
name: binmode
- !ruby/object:RI::MethodSummary
name: binmode=
- !ruby/object:RI::MethodSummary
name: cmd
- !ruby/object:RI::MethodSummary
name: login
- !ruby/object:RI::MethodSummary
name: preprocess
- !ruby/object:RI::MethodSummary
name: print
- !ruby/object:RI::MethodSummary
name: puts
- !ruby/object:RI::MethodSummary
name: telnetmode
- !ruby/object:RI::MethodSummary
name: telnetmode=
- !ruby/object:RI::MethodSummary
name: waitfor
- !ruby/object:RI::MethodSummary
name: write
name: Telnet
superclass: SimpleDelegator
|