CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
can't telnet Windows 2008 R2 64 bit, same function works for windows 32BIT (2003, xp)

 



vaviad
New User

Aug 16, 2011, 1:23 AM

Post #1 of 2 (5790 views)
can't telnet Windows 2008 R2 64 bit, same function works for windows 32BIT (2003, xp) Can't Post

Hi,

I have some problem to telnet to Windows 64BIT, same script works just fine on windows 32 bit.

I use telnet.pm module

my function is:
sub OpenTelnetConectionWindows
{
my $lh_ref = shift;
my $host_ref = shift;
my $Account_ref= shift;
my $AccountPass_ref = shift;
my $TelnetLifeCheck;

my $this_subs_name = (caller(0))[3];
$$lh_ref->log("Function: $this_subs_name");

$$lh_ref->log_print("Open Telnet Conection on $$host_ref on account $$Account_ref.");

my $telnet = new Net::Telnet ( Timeout => 20000,
Prompt => '/[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/',
#Prompt => '/(?m:^[\w.&-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$)/',
#Prompt => '/C:\\\\>$/i',
Dump_log => 'dump.log',
Input_log => 'InputLog.txt',
Output_log => 'OutputLog.txt'
);
$telnet->open("$$host_ref");
$telnet->waitfor('/\d*[Ll]ogin:\s*/'); #$telnet->waitfor('/login: $/i');
$telnet->print($$Account_ref);
$telnet->waitfor('/\d*[Pp]assword:\s*/'); #$telnet->waitfor('/password: $/i');
$telnet->print($$AccountPass_ref);


my $str = 'hostname';
my @tmp = $telnet->cmd($str);
print @tmp;

return $telnet;
}

i get error message:
pattern match read eof at D:\Documents and....

then i add this lines:
my $str = 'hostname';
$telnet->errmode(sub {die @_ unless $_[0] =~ /eof/});
$telnet->errmode();
my @tmp = $telnet->cmd($str);
print @tmp;
but i dont get any prints, but when i try to print again i get:
write error: filehandle isn't open at D:\Documents and

than mean that telnet connection doesn't open

i work with input and dump log but i can't understand where i get wrong...

this function work on windows 32 bit.
Any suggestions?

Thanks
Aviad


rovf
Veteran

Aug 22, 2011, 1:00 AM

Post #2 of 2 (5482 views)
Re: [vaviad] can't telnet Windows 2008 R2 64 bit, same function works for windows 32BIT (2003, xp) [In reply to] Can't Post

(1) You don't check the return code of your Telnet functions

(2) In your application, you have strict and warnings enabled, haven't you?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives