title: Net::SSH::Perl module: Executing multiple commands
body: <p>I want to execute two commands in a single line using Net::SSH::Perl module..</p>
  
  <p>Actually first command sets some env variable, second runs some command which needs the env variable to be set for that shell.</p>
  
  <p>How to make the below piece of code work</p>
  
  <p>Eg:</p>
  
  <pre><code>use Net::SSH::Perl;
  my $hostname = "&lt;&lt;hostname&gt;&gt;";
  my $username = "&lt;&lt;username&gt;&gt;";
  my $password = "&lt;&lt;password&gt;&gt;";
  
  my $cmd = 'export PATH= *** ; java -version';
  
  my $ssh = Net::SSH::Perl-&gt;new("$hostname", debug=&gt;0);
  $ssh-&gt;login("$username","$password");
  
  my ($stdout,$stderr,$exit) = $ssh-&gt;cmd("$cmd");
  print $stdout;
  </code></pre>
  
  <p>This question is already asked in this site, but there are no answers.</p>
  
  <p>Calling <code>$ssh-&gt;cmd</code> several times won't work, because the two calls will not be invoked in the same session.</p>