I need to establish an ssh connection and execute commands remotely, and the flow is: connect by ssh, open a new shell by command line and finally execute the commands.
use Net::SSH::Perl;
my $ssh = Net::SSH::Perl->new('test.com');
$ssh->login('user', 'pass');
my($stdout, $stderr, $exit) = $ssh->cmd('shell');
my($stdout, $stderr, $exit) = $ssh->cmd('ls -l');
print($stdout);
but when you run $ssh->cmd('shell'); it waits, I assume that this opens the shell and since it is a "command" that does not end, it does not pass to the next command which would be to make an ls.
I need to execute commands in the new shell opened by ssh. It is not possible to modify absolutely anything on the remote machine.
Any solution in perl or python will help :)