title: execute command telnet via perl script
body: <p>I'm trying to excute a command via a Perl script using telnet, it seem that the script below is able to log in successfully, but can't execute the command. I coudn't find the right regular expression that will wait the prompt <code>&gt;</code> before executing the command.</p>
  
  <p>Here is an image of the result when login normaly via telnet:</p>
  
  <p><img src="https://i.stack.imgur.com/dKwVq.png" alt="screenshot"></p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use Net::Telnet;
  my $remote_host = 'myrouter';
  my $telnet = new Net::Telnet  (Timeout=&gt;10  ,Input_log =&gt; "received_data.txt" );
  $telnet-&gt;open($remote_host);
  $telnet-&gt;waitfor('/ADSL2PlusRouter login:/i');
  $telnet-&gt;print('mylogin'); 
  $telnet-&gt;waitfor('/Password:/i');
  $telnet-&gt;print('my_password');
  $telnet-&gt;waitfor('/-*&gt;/');
  $telnet-&gt;cmd("adsl show");
  $telnet-&gt;print('exit');
  </code></pre>