Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Pass local bash script to remote host via SSH

by haukex (Archbishop)
on Jun 24, 2020 at 09:55 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-19 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found