#!/usr/local/bin/perl -w use Net::SSH qw(sshopen3); use strict; Main: { my $host = 'nobody@nowhere.com'; my @command = ('ls -al;', 'echo Howdy!'); my $reader = IO::File->new(); my $writer = IO::File->new(); my $error = IO::File->new(); sshopen3( $host, $writer, $reader, $error, @command ) or die $!; local $/ = undef; my $output_stream = <$reader>; my $error_stream = <$error>; if ( length $error_stream ) { print "SSH error: $error_stream"; } if ( length $output_stream ) { print "SSH output: $output_stream"; } }