ypcat has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I am attempting to use Net::Telnet::Cisco to connect to my router and then from there connect to port 25 on a mail server. However, I am running into strange issues with it. The error is:

command timed-out at ciscomailtester.pl

#!/usr/bin/perl use strict; use Net::Telnet::Cisco; my ($router, $mail, $line, $routeruser, $routerpass); $router = "1.1.1.1"; $routeruser="user"; $routerpass="pass"; $mail = Net::Telnet::Cisco->new(Host => "$router"); $mail->login("$routeruser", "$routerpass"); $mail->cmd('telnet 2.2.2.2 25'); $mail->close;
Please keep in mind I can run all other router commands and get the results I would expect, but when telneting out using the cmd() it gives the time out error. Note: The command does work if I do exactly what the script is doing.. i.e. telnet to my router login with the user and pass and then telnet to my mail server via the identical command. So this leads me to believe the problems lie's within Net::Telnet::Cisco. I also tried putting the command inside $mail->print('telnet 2.2.2.2 25');, however I did not have any luck this route either. Please let me know if you have any ideas.

Thanks,
YpCat

Replies are listed 'Best First'.
Re: Net Telnet Cisco Complications
by zengargoyle (Deacon) on Mar 19, 2002 at 06:13 UTC

    It's likely your telnet is working. But the prompt your mail server is using isn't the prompt that Net::Telnet::Cisco is using. So it never matches the expected 'router>' prompt and therefore times out.

    You'll have to play with the prompt.

    Why are you doing this in the first place. It feels wrong.

      Hehe it feels wrong, I knew someone would think something. No I am not doing anything wrong. I work for an ISP and the lead engineer saw the code I was working, which was a script that sends and receives mail on all our mail servers. Then he started making suggestions, and his best suggestion was to source my telnet to the mail servers off the routers that way when I connected to the mail server it would be just like I was a customer.


      Thanks,
      YpCat