I am working on an application that needs to send commands to remote servers. Sending commands is quite simple using many SSH client libraries.
However, I would like the shell state to be maintained between each command (that is, the current working directory, environment variables, etc.). All the client libraries I have seen do not do this. For example, the following code example that does not do what I want:
use Net::SSH::Perl; my $server = Net::SSH::Perl->new($host); $server->login($user, $pass); $server->cmd('cd /var'); $server->cmd('pwd');
Other tasks will be performed between sending commands, so combining commands like $server->cmd('cd /var; pwd') not acceptable.
source share