use Net::OpenSSH; my $ssh = Net::OpenSSH->new('foo@host'); $ssh->error and die "unable to connect: " . $ssh->error; my $pipe = $ssh->pipe_out("snap.sh"); while(<$pipe>) { print $_; }