title: Perl expect output of executed command
body: <p>i wrote a little script which executes the ls command. Now I want to store the output of that command in a variable to work with it in the further perl script. Unfortunately I cannot grab the output from the ls command. </p>
  
  <pre><code>my ($core) = "servername";
      my $tel_con = "ssh ".$core. " -l $user";
  
      $ssh = Expect-&gt;spawn("$tel_con");
      $ssh-&gt;log_stdout(1);
  
      unless ( $ssh-&gt;expect( 5, -re =&gt; '$' ) ) {
              return "Never connected " . $ssh-&gt;exp_error() . "\n";
      }
      sleep 1;
      $ssh-&gt;send_slow(0, "ls -l\r");
      $ssh-&gt;clear_accum();
      my $str = $ssh-&gt;exp_after();
      print "STR = '$str'\n";
  </code></pre>
  
  <p>Maybe you can give me some help please?</p>