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

Hi Guys why is not working this script when i telnet to other remote host it does not work. you can see the output of script

#!/usr/bin/perl use 5.010; use strict; use warnings; use Net::Telnet; ## Global variables. my $Term; my $telnet; my $user = "deneme"; my $passwd = "Try123."; print "Enter your IP : "; my $host = readline STDIN; chomp $host; my $prompt = '/(?:Password: |[>])/m'; # your regexp for shell + prompt here open my $Bm_Report, "> BM_Report.txt" or die "can't open the file: + $!\n"; $telnet = new Net::Telnet (Timeout => 1000, Errmode=>'die'); $telnet->input_log($Bm_Report); $telnet->open($host); $telnet->login($user, $passwd); print $telnet->cmd("--------------- $host ----------------"); print $telnet->cmd('cat /tmp'); $telnet->cmd('telnet 100.0.2.1'); $telnet->waitfor('login:'); $telnet->print("deneme"); $telnet->waitfor('Password: '); $telnet->print("Try123."); $telnet->close;

MontaVista(R) Linux(R) Carrier Grade Edition 4.0 (0600995) Linux/ppc 2.6.10_mvlcge401-8555-cplab EC1830-81-1 login: appl Password: Last login: Fri Jul 1 04:05:01 2016 from 10.2.3.93 on pts/2 Linux EC1830-81-1 2.6.10_mvlcge401-8555-cplab #2 Sun Apr 6 12:02:41 ED +T 2014 ppc GNU/Linux Welcome to MontaVista(R) Linux(R) Carrier Grade Edition 4.0 (0600995). No directory, logging in with HOME=/ appl@EC1830-81-1-ACT:/ $ --------------- 10.2.3.55 ---------------- -sh: ---------------: command not found appl@EC1830-81-1-ACT:/ $ cat /tmp Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: SMART CF Model: Rev: 0000 Type: Direct-Access ANSI SCSI revision: 02 appl@EC1830-81-1-ACT:/ $ telnet 100.0.2.1 Trying 100.0.2.1... Connected to 100.0.2.1. Escape character is '^]'. MontaVista(R) Linux(R) Carrier Grade Edition 4.0 (0600995) Linux/ppc 2.6.10_mvlcge401-8555-cplab EC1830-2-1 login: WHY HAS NOT BEEN WRITTEN " deneme "

Replies are listed 'Best First'.
Re: telnet from host to remote host
by NetWallah (Canon) on Aug 31, 2016 at 21:39 UTC
    It is possible that the connection created by the "telnet 100.0.2.1" command is not echoing sent characters.

    You may need to send ^E to toggle echo.

    The best bet is to debug the traffic: ($telnet->dump_log($filename)).

            "Software interprets lawyers as damage, and routes around them" - Larry Wall

      I have changed it by typing double quotes "telnet 100.0.2.1" still same.

        • Have you tried sending ^E (Control E) as suggested in my previous post ?
        • Did you get a debug log file as suggested in my previous post ?

                "Software interprets lawyers as damage, and routes around them" - Larry Wall