telnet timed out

P

Petterson Mikael

Hi,

I am using Net::Telnet module in perl to connect to a remote client.
I get a timeout for '$telnet->login($username, $password);'.

timed-out waiting for command prompt at ./telnet.pl line 15

Any ideas why?

I have tried with regular telnet and it works!

//Mikael


Script
-------------------------------------------
#!/vobs/cello/cade_struct/bin/perl -w

use Net::Telnet;

my $hostname = 'ws3196.rnd.ki.sw.ericsson.se';
my $username = 'eraonel';
my $password = 'test';


my $telnet = new Net::Telnet ( Timeout=>30,
Errmode=>'die');


$telnet->open($hostname);
$telnet->login($username, $password);
$telnet->waitfor('/login:.*$/');
print $telnet->cmd('whoami');

This is how my telnet login looks like:
***************************************

Trying 147.214.201.190...
Connected to ws3196.
Escape character is '^]'.


SunOS 5.8

login:

****************************************
 
C

chris-usenet

The first documentation illustration shows a Prompt parameter in here
rather than needing to use waitfor().


This chunk will wait for a prompt of "login:" AFTER having logged in,
before issuing the whoami command. I suspect this isn't what you want.

The prompt looks like this:
ast login: Wed Jan 19 09:15:41 from ws3196
Sun Microsystems Inc. SunOS 5.8 Generic Patch December 2002
ws3196{NONE}[espresso/rbssw/1.1]

Is there a space after the ']' character?

I am using the following (code below) but I still get a timeout.
$telnet->open("$hostname");
$telnet->login("$username", "$password");
$telnet->waitfor('.[\]] $');
$telnet->cmd('who');
$telnet->close;

Your waitfor parameter is incorrect - you've missed the apparently
mandatory // characters around the RE. Try this instead, which matches
"[espresso/rbssw/1.1]", where espresso and rbssw can be replaced by
any word, the 1.1 can be replaced by any decimal number, and there is
possibly a trailing space:

$telnet->waitfor('/\[w+\/w+\/\d+\.\d+\] ?$/');

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top