in reply to Re: Timeout parameter for Net::Telnet under Windows
in thread Timeout parameter for Net::Telnet under Windows

Ok, so I tried this. But I don't know exactly how to pull it off.

I took the Host out of the new() constructor so that the constructor would not call open(), and added these lines of code:

289 t->{Host} = $host; 290 t->SUPER::timeout(1); 291 t->open();
I get this error:
Error: Not a HASH reference at line test.pl line 289.

Replies are listed 'Best First'.
Re^3: Timeout parameter for Net::Telnet under Windows
by Mr. Muskrat (Canon) on Jan 22, 2016 at 19:07 UTC

    I haven't tried this on Windows yet so your mileage may vary.

    #!/bin/env perl use strict; use warnings; use Net::Telnet; my $host = '192.168.130.112'; # valid host that is offline my $port = 10001; print "DEBUG 1\n"; my $t = new Net::Telnet ( Port => $port, Prompt => '/Escape character is.+\n/', Rs => ' ', Ors => '', Binmode => 1, Telnetmode => 1, Errmode => 'return'); print "DEBUG 2\n"; if (!$t) { die "Failed to create telnet object\n"; } $t->open(Host => $host, Timeout => 1) or die "Failed to create telnet session\n";
      I tried this. The results are the same. It is taking 20 to 30 seconds before it times out.

        Bummer. I tried using $t->SUPER::timeout(1) but it generated an error so I removed it before posting.