title: Store ouput over ssh using Net::SSH::Expect
body: <p>student worker here. It's my first time working with perl, and I seem to have ran out of solutions, so I need your help!</p>
  
  <p>I'm trying to store the ouput of a command on an HP Storeonce 3540 in a variable through the ssh module so I can extract some
  information I want to monitor:</p>
  
  <p>Not sure if it's useful, but FYI the output is this:</p>
  
  <p>system/show> performance</p>
  
  <pre><code>Service Set 1
   Storage Usage
     Current: xxxxx TB
     Maximum: xxxxx TB
   Throughput
     VTL Read: 0 MB/s
     VTL Write: 0 MB/s
     NAS Read: 0 MB/s
     NAS Write: 0 MB/s
     Catalyst Read: 0 MB/s
     Catalyst Write: 0 MB/s
   Replication
     Inbound: 0 MB/s
     Outbound: 0 MB/s
   Catalyst
     Inbound: 0 MB/s
     Outbound: 0 MB/s
  </code></pre>
  
  <p>Here's the code:</p>
  
  <pre><code>use Net::SSH::Expect;
  use Capture::Tiny ':all';
  use Backticks;
  ( ... )
    my $ssh = Net::SSH::Expect-&gt;new (
            host =&gt; $hp_host,
            password=&gt; $hp_pwd,
            user =&gt; $hp_user,
            raw_pty =&gt; 1,
            timeout =&gt; 20
           );
    my $login_output = $ssh-&gt;login();
    if ($login_output !~ /&gt;/)
     {
      die "Login has failed. Login output was $login_output";
     }
    $ssh-&gt;send("system");
    $ssh-&gt;waitfor('\&gt;\s*\z', 5) or die "Error #1-system";
    $ssh-&gt;send("show");
    $ssh-&gt;waitfor('\&gt;\s*\z', 5) or die "Error #2-show";
  </code></pre>
  
  <p>Here I want to store the "performance" command's output.
    I have tried a bunch of combinations so here it goes:</p>
  
  <p>1 - 
  <code>say '$ssh-&gt;send("performance")'-&gt;stdout;</code></p>
  
  <p>gets me this error:</p>
  
  <p><code>String found where operator expected at script_hpstoreonce.pl line 67, near "say '$ssh-&gt;send("performance")'"
          (Do you need to predeclare say?)
  syntax error at script_hpstoreonce.pl line xx, near "say '$ssh-&gt;send("performance")'"</code></p>
  
  <p>2 - 
  <code>Backticks-&gt;run( '$ssh-&gt;send("performance")' );
  print $stdout;</code></p>
  
  <p>It does not print the output</p>
  
  <p>3 - 
  Every time I put the <code>"$ssh-&gt; "</code> in front of the command I get this error:</p>
  
  <p>ex:
  <code>$ssh-&gt;Backticks-&gt;run( 'send("performance")' );</code>
  or
  <code>$string = $ssh-&gt;tee('performance');</code></p>
  
  <p>error:
  <code>Can't locate object method "Backticks"/or("Tee")/ via package "Net::SSH::Expect" at script_hpstoreonce.pl line xx.</code></p>
  
  <p>4 - 
   <code>$test = Backticks-&gt;stdout('performance');
   print $stdout;</code>
   or
   <code>print $test;</code></p>
  
  <p>error:
  <code>Can't locate object method "Backticks" via package "Net::SSH::Expect" at script_hpstoreonce.pl line xx.</code></p>
  
  <p>5 - 
  I also tried to use the Capture::Tiny module but again:</p>
  
  <p><code>$stdout = capture { $ssh-&gt;send("performance") };
   print $stdout;</code></p>
  
  <p>gets me this error:</p>
  
  <p><code>Can't locate object method "capture" via package "Net::SSH::Expect" at script_hpstoreonce.pl line xx.</code></p>
  
  <p>but</p>
  
  <p><code>($stdout, $stderr) = capture {$ssh-&gt;send("performance")};
    print $stdout;</code></p>
  
  <p>or</p>
  
  <p><code>$stdout = capture_stdout{$ssh-&gt;exec("performance")};
   print $stdout;</code></p>
  
  <p>or</p>
  
  <p><code>my($stdout, $stderr, $exit) = $ssh-&gt;send('performance');
   print $stdout;</code></p>
  
  <p>or</p>
  
  <p><code>$stdout = $ssh-&gt;capture('performance');
   print $stdout;</code></p>
  
  <p>Does not print anything when I run the script.</p>
  
  <p>6 - 
  Same thing goes for Tee:</p>
  
  <p><code>$string = tee {$ssh-&gt;send("performance")};
   print $string;</code></p>
  
  <p>Doesn't print anything</p>
  
  <p>Since the same errors are popping up even when I use different modules, I understand that I'm probably
   missing something due to my lack of knowledge of the language and my lack of experience, but I can't 
   seem to find what's wrong here. Is the problem in the <code>$ssh-&gt;</code> protocole??</p>
  
  <p>Thank you </p>