#!/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; #### # open_ex: ['ssh','-O','check','-T','-S','/root/.libnet-openssh-perl/user-10.253.10.10-25248-962213','-l','user','10.253.10.10','--'] # _waitpid(25251) => pid: 25251, rc: 0, err: # open_ex: ['ssh','-S','/root/.libnet-openssh-perl/user-10.253.10.10-25248-962213','-l','user','10.253.10.10','--'] Pseudo-terminal will not be allocated because stdin is not a terminal. # _waitpid(25252) => pid: 25252, rc: 65280, err: Couldn't run remote command: child exited with code 255 at script.pl line 42. # open_ex: ['ssh','-O','exit','-T','-S','/root/.libnet-openssh-perl/user-10.253.10.10-25248-962213','-l','user','10.253.10.10','--'] # _waitpid(25253) => pid: 25253, rc: 0, err: