I want to execute several commands in the same session after connecting to the server using 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 was expecting the following output:
/usr/script
but instead I get:
/home/user
How can I execute several commands in one session?
source share