From: "Bermejo, Rodrigo" Date: 2003-07-01T00:50:56+09:00 Subject: Re: Stuck in the middle with Telnet I have implemented my own class for telnet stuff, may it helps you.. #!/usr/bin/ruby #-----------------> require 'net/telnet' class RemoteHost def initialize(login,password,hosts,timeout=100) hosts=hosts.to_a @login=login @password=password @hosts=hosts @timeout=timeout end def command(commands) results={} @hosts.each { |host| begin results[host]=[] connectedHost = Net::Telnet.new({"Host" => host, "Timeout" => @timeout}) connectedHost.login(@login,@password) co=Hash.new commands.each {|command| co[command]=connectedHost.cmd(command).sub(command,"") } connectedHost.close results[host]=co rescue Exception => err results[host]=err #return #{err} ,"n" next end } return results end end host=RemoteHost.new("root","neverguess","myhosts") res=host.command("whoami") p res["myhost"]["whoami"] kingsley@icecode.org wrote: >yes I did and no luck > >But the documentation says login used login: and password: to match >against - my mud used What is your name: and password: > > > >On 06-30-2003 04:14 pm, you wrote: > > > >>Did you try with \'tn.login(\"me\", \"let me in\")\'? >> >>Guillaume. >> >>On Mon, 2003-06-30 at 10:14, kingsley@icecode.org wrote: >> >> >>>Hi >>> >>>I am trying to write my own telnet client to connect to my >>> >>> >favourite > > >>>MUD. (http://www.anguish.org/) >>> >>>I\\\'m stuck - I can\\\'t make it login at all ! I don\\\'t quite >>> >>> >understand > > >>>the concept. >>> >>>Do I use tn.cmd(\\\"mudcommand\\\") to do pass the commands? Like >>> >>> >: > > >>>input = gets.chomp #look at tree >>>tn.cmd(input) {|str| print str} #you look at a tree >>> >>>here\\\'s what I have that doesnt work..note - If I just change the >>> >>> >login > > >>>name (string) to guest and delete the password line - it does log >>> >>> >in as > > >>>guest (which requires no password). >>> >>>require \\\'net/telnet\\\' >>> >>>require \\\'net/telnet\\\' >>>tn = Net::Telnet.new(\\\'Host\\\' => >>> >>> >\\\'ancient.anguish.org\\\', > > >>> \\\'Port\\\' => \\\'2222\\\', >>> \\\'Timeout\\\' => 60, >>> \\\'Telnetmode\\\' => true) { |str| print str >>> >>> >} > > >>>tn.cmd(\\\"Match\\\" => \\\"What is your name: \\\", \\\"String\\\" >>> >>> >=> \\\"myname\\\") > > >>>{ |str| print str } >>>tn.waitfor(\\\"Match\\\" => \\\"Password: \\\", \\\"String\\\" => >>> >>> >\\\"mypassword\\\") { > > >>>|str| print str } >>> >>>Thanks >>> >>>btw - I have also tried to make the password command a tn.cmd, >>> >>> >tn.write > > >>>and tn.print but with no success. >>> >>>Kingsley >>> >>> >>> >> >> >> >> >> -- |CIAT - General Electric Rodrigo Bermejo Information Technologies. Dial comm:8*879-0644 mailto:rodrigo.bermejo@ps.ge.com