#!/usr/bin/perl use strict; use warnings; use diagnostics; use Net::SSH::Perl; my $remote_host = 'localhost'; my $password = 'yourpassword'; my $username = 'yourusername'; my $cmd = 'if [ -d $test_dir ]; then echo 1; else echo 0; fi'; warn "Starting SSH Services:..."; my $ssh = Net::SSH::Perl->new($remote_host, protocol => '1,2'); print "done", "\n"; warn "Starting Login:..."; $ssh->login($username, $password); print "login done", "\n"; my $test_dir = '/foo/bar'; warn "Starting command:..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout, "\n";