in reply to Re: SSH and expect without module
in thread SSH and expect without module
The Monks here were kind enough to help me get Net::OpenSSH installed on an older system where updates were, uh, problematic. But I was further stymied by the age of the underlying ssh client, which was incompatible. So I offer the following:
sub ops_do_ssh_qx { my ($cmd) = @_; $cmd->{ssh_cmd} = 'ssh ' . $cmd->{user} . '\@' . $cmd->{host} . ' +\'' . $cmd->{command} . '\'' . ' 2>/dev/null'; $cmd->{output} = qx($cmd->{ssh_cmd}); if ( defined $cmd->{output} ) { $cmd->{cmd_ret_code} = $?; chomp $cmd->{output}; } else { ($cmd->{ssh_ret_code}, $cmd->{ssh_ret_msg}) = (0 + $!, '' . $!); } return $cmd; }
It does rely on ssh keys being setup properly.
I hope you find it useful.
Thanks,
cbeckley
|
|---|