Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Pass local bash script to remote host via SSH

by haukex (Bishop)
on Jun 24, 2020 at 09:55 UTC ( #11118409=note: print w/replies, xml ) Need Help??


in reply to Pass local bash script to remote host via SSH

Note that I can't run Net::SSH since I don't have access to additional modules

Yes, even you can use CPAN - Net::OpenSSH is a pure-Perl module with no dependencies, which means it can be simply copied over.

use Net::OpenSSH; my $ssh = Net::OpenSSH->new($host); die "Couldn't establish SSH connection: ".$ssh->error if $ssh->error; my ($in, $pid) = $ssh->pipe_in('bash','-s') or die "pipe_in failed: ".$ssh->error; print $in <<'EOF'; # ... EOF close $in or die "close failed";

Replies are listed 'Best First'.
Re^2: Pass local bash script to remote host via SSH
by salva (Canon) on Jun 25, 2020 at 06:59 UTC
    Even shorter...
    use Net::OpenSSH; die "Couldn't establish SSH connection: ".$ssh->error if $ssh->error; $ssh->system({stdin_data => <<EOD}, 'bash', '-s') or die "command fail +ed: " . $ssh->error; # ... EOD

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2022-01-28 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (74 votes). Check out past polls.

    Notices?