#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; my $user = ""; my $passwd = ""; my $host = ""; my @cmd = "show clock"; my @quitcmd = "exit"; my $ssh = Net::OpenSSH->new("$host", user => "$user", passwd => "$passwd", timeout => 90 ); $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error; my @output = $ssh->capture({stdin_data => "@cmd\n@quitcmd\n"}); $ssh->error and die "Couldn't run remote command: ". $ssh->error; #close the ssh session undef $ssh;