#!/usr/bin/perl # vi:ts=4 sw=4 et: use strict; use warnings; use Net::SSH::Perl; my $ssh = Net::SSH::Perl->new( 'localhost' ) or die "ssh->new: $!"; $ssh->login(); # Achtung! zwei Kommandos in einem Aufruf! my ( $out, $err, $exit ) = $ssh->cmd( 'cd /var/tmp; pwd' ); printf "Exitcode: %d\nOutput: %s\nError: %s\n--\n", $exit, $out || '', $err || ''; ( $out, $err, $exit ) = $ssh->cmd( 'pwd' ); printf "Exitcode: %d\nOutput: %s\nError: %s\n--\n", $exit, $out || '', $err || '';