#!/usr/bin/perl use Expect; use strict; use warnings; use Data::Dumper; use Net::SSH::Perl; # SSH connection through Perl $| = 1; my $host = xxxx; my $port = xxxx; my $user = xxxx; my $password = xxxx; my $cmd = `ls -l`; # my $cmd = `/bin/bash test.sh`; #system("/bin/bash test.sh") == 0 # or die "Bash Script failed"; my $ssh = Net::SSH::Perl->new( "".$host."" , port => "".$port."" , protocol => 2 , interactive => 1 , batchMode => 1 , RhostsAuthentication => 1, debug => 1 ); $ssh->login("".$user."","".$password.""); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); #$ssh->shell; print $stdout; $ssh->cmd("exit");