Linux heracles.o2switch.net 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
/
opt
/
alt
/
ruby21
/
share
/
ri
/
2.1.0
/
system
/
Net
/
Telnet
/
//opt/alt/ruby21/share/ri/2.1.0/system/Net/Telnet/cdesc-Telnet.ri
U:RDoc::NormalClass[iI"Telnet:ETI"Net::Telnet;TI"Object;To:RDoc::Markup::Document:@parts[o;;[ S:RDoc::Markup::Heading: leveli: textI"Net::Telnet;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I"*Provides telnet client functionality.;T@o; ;[ I"CThis class also has, through delegation, all the methods of a ;TI"Esocket object (by default, a +TCPSocket+, but can be set by the ;TI"G+Proxy+ option to <tt>new()</tt>). This provides methods such as ;TI"H<tt>close()</tt> to end the session and <tt>sysread()</tt> to read ;TI"Hdata directly from the host, instead of via the <tt>waitfor()</tt> ;TI"Emechanism. Note that if you do use <tt>sysread()</tt> directly ;TI"Fwhen in telnet mode, you should probably pass the output through ;TI"?<tt>preprocess()</tt> to extract telnet command sequences.;T@S; ; i;I" Overview;T@o; ;[ I"EThe telnet protocol allows a client to login remotely to a user ;TI"Kaccount on a server and execute commands via a shell. The equivalent ;TI"Dis done by creating a Net::Telnet class with the +Host+ option ;TI"Eset to your host, calling #login() with your user and password, ;TI"Aissuing one or more #cmd() calls, and then calling #close() ;TI"Ato end the session. The #waitfor(), #print(), #puts(), and ;TI"B#write() methods, which #cmd() is implemented on top of, are ;TI"=only needed if you are doing something more complicated.;T@o; ;[I"DA Net::Telnet object can also be used to connect to non-telnet ;TI"Aservices, such as SMTP or HTTP. In this case, you normally ;TI">want to provide the +Port+ option to specify the port to ;TI"Econnect to, and set the +Telnetmode+ option to false to prevent ;TI"Gthe client from attempting to interpret telnet command sequences. ;TI"EGenerally, #login() will not work with other protocols, and you ;TI",have to handle authentication yourself.;T@o; ;[I"EFor some protocols, it will be possible to specify the +Prompt+ ;TI"Ioption once when you create the Telnet object and use #cmd() calls; ;TI"Cfor others, you will have to specify the response sequence to ;TI"@look for as the Match option to every #cmd() call, or call ;TI"D#puts() and #waitfor() directly; for yet others, you will have ;TI">to use #sysread() instead of #waitfor() and parse server ;TI"responses yourself.;T@o; ;[I"GIt is worth noting that when you create a new Net::Telnet object, ;TI"Cyou can supply a proxy IO channel via the Proxy option. This ;TI"Fcan be used to attach the Telnet object to other Telnet objects, ;TI"Dto already open sockets, or to any read-write IO object. This ;TI"Dcan be useful, for instance, for setting up a test fixture for ;TI"unit testing.;T@S; ; i;I" Examples;T@S; ; i;I"<Log in and send a command, echoing all output to stdout;T@o:RDoc::Markup::Verbatim;[I"9localhost = Net::Telnet::new("Host" => "localhost", ;TI"3 "Timeout" => 10, ;TI"< "Prompt" => /[$%#>] \z/n) ;TI"=localhost.login("username", "password") { |c| print c } ;TI".localhost.cmd("command") { |c| print c } ;TI"localhost.close ;T:@format0S; ; i;I"/Check a POP server to see if you have mail;T@o;;[I"Dpop = Net::Telnet::new("Host" => "your_destination_host_here", ;TI"+ "Port" => 110, ;TI"3 "Telnetmode" => false, ;TI"2 "Prompt" => /^\+OK/n) ;TI"=pop.cmd("user " + "your_username_here") { |c| print c } ;TI"=pop.cmd("pass " + "your_password_here") { |c| print c } ;TI"%pop.cmd("list") { |c| print c } ;T;0S; ; i;I"References;T@o; ;[ I"GThere are a large number of RFCs relevant to the Telnet protocol. ;TI"DRFCs 854-861 define the base protocol. For a complete listing ;TI"of relevant RFCs, see ;TI"Ahttp://www.omnifarious.org/~hopper/technical/telnet-rfc.html;T: @fileI"lib/net/telnet.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[ I" sock;TI"R;T:publicFI"lib/net/telnet.rb;T[ [ [[I" class;T[[;[[I"new;T@h[:protected[ [:private[ [I" instance;T[[;[[I"binmode;F@h[I" binmode=;F@h[I" close;F@h[I"cmd;F@h[I" login;F@h[I"preprocess;F@h[I" print;F@h[I" puts;F@h[I"telnetmode;F@h[I"telnetmode=;F@h[I"waitfor;F@h[I" write;F@h[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@cI"Net;FcRDoc::NormalModule