use Net::SSH::Perl; my ($host,$user,$pw) = @_; my $cmd = "ls"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pw); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); return $exit;