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