Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: SSH and expect without module

by cbeckley (Curate)
on Mar 15, 2017 at 20:54 UTC ( #1184770=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1184770]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-05-25 03:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (143 votes). Check out past polls.

    Notices?