Hi Mikel,
I have used TimeoutError with the rescue statement, which works
fine when I hardcore the credentials, but the problem is when I want to
login again by asking the user to enter his credentials, it just jumps
out.
Trying 172.20.25.154...
Connected to 172.20.25.154.
Red Hat Enterprise Linux Server release 5 (Tikanga)
Kernel 2.6.18-PIANO-RHEL5 on an i686
login: prasad
Password:
Login incorrect
login: The username or password is incorrect.
Please try again ...
Enter user name :
Enter password :
User name is => #<IO:0xb7f6cf7c>
Password for #<IO:0xb7f6cf7c> is => #<IO:0xb7f6cf7c>
Trying 172.20.25.154...
Connected to 172.20.25.154.
Red Hat Enterprise Linux Server release 5 (Tikanga)
Kernel 2.6.18-PIANO-RHEL5 on an i686
/usr/lib/ruby/1.8/net/telnet.rb:634:in `puts': undefined method `+' for
#<IO:0xb7f6cf7c> (NoMethodError)
from /usr/lib/ruby/1.8/net/telnet.rb:676:in `cmd'
from /usr/lib/ruby/1.8/net/telnet.rb:722:in `login'
from try.rb:23
Regards,
Prasad.
Mikel Lindsaar wrote:
> On Jan 15, 2008 11:14 PM, Prasad Pednekar <prasadm29 / gmail.com> wrote:
>> I was trying out the following snippet of code and just wanted to
>> know why the rescue doesn't work when the username or password are not
>> valid. The code works fine when both are valid, but I wanted to catch
>> invalid login error and take action, but so far can't do so.
>
> It's because not all exceptions are created equal :)
>
> Some (most) are inherited from StandardError, which you will catch
> with a simple rescue statement, others come from other parent classes.
>
> Here is a short write up on it for you, it talks about Net::POP3, but
> you are probably running into the same thing:
>
> http://lindsaar.net/2007/12/9/rbuf_filltimeout-error
>
> Regards
>
> Mikel
--
Posted via http://www.ruby-forum.com/.