I want to execute multiple commands in the same session after connecting to a server with Net::SSH::Any.
My sample code is as follows:
use strict;
use warnings;
use Net::SSH::Any;
my $host = "ip address";
my $user = "user";
my $passwd = "pass";
my $cmd1 = 'cd /usr/script';
my $ssh = Net::SSH::Any->new($host, user => $user, password => $passwd);
$ssh->system($cmd1);
my $pwd = $ssh->capture("pwd");
print $pwd;
I expected the following output:
/usr/script
but instead I am getting:
/home/user
How can I execute multiple commands in a single session?