title: Perl ssh connection and execute telnet connection
body: <p>I have multiple cisco routers configured with telnet access allowed from 5 specified hosts. Now I want to execute a perl script on one host which connects via ssh to the other hosts and checks if telnet to the router is possible.
  I tried the system "ssh host" command but unfortunately with no joy. Could somebody help me please?</p>
  
  <p>Many thanks in advance.</p>
  
  <p>I tried the following but with no success. Some ideas?</p>
  
  <pre><code>
  use Net::OpenSSH;
  
  $ssh = Net::OpenSSH->new("linuxserver", user => "username", password => "password", master_stderr_discard => 1);
  $command = "telnet routername";
  @out = $ssh->capture({stdin_data => "routerpassword\n"}, $command);
  
  print "@out\n";
  
  
  </code></pre>