title: Perl execute a command at a specified time
body: <p>I need to write a perl script that executes a command at a specified time.</p>
  
  <ol>
  <li>use net::ssh::expect to login to a router</li>
  <li>read the time from the router's clock ("show clock" command displays the time.)</li>
  <li>At the 17:30:00 execute a command.</li>
  </ol>
  
  <p>I tried writing script for it but it doesn't work. Any suggestions please ?</p>
  
  <pre><code>use strict;
  use warnings;
  use autodie;
  use feature qw/say/;
  use Net::SSH::Expect;
  
  my $Time;
  my $ssh = Net::SSH::Expect-&gt;new(
      host     =&gt; "ip",
      password =&gt; 'pwd',
      user     =&gt; 'user name',
      raw_pty  =&gt; 1,
  );
  
  my $login_output = $ssh-&gt;login();
  
  while(1) {
      $Time = localtime();
      if( $Time == 17:30:00 ) {
          my $cmd = $ssh-&gt;exec("cmd");
          print($cmd);
      } else {
          print" Failed to execute the cmd \n";
      }
  }
  </code></pre>