Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Pass local bash script to remote host via SSH (updated)

by soonix (Canon)
on Jun 24, 2020 at 06:20 UTC ( #11118404=note: print w/replies, xml ) Need Help??


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

use strict; use warnings; open(my $out_fh, "|-", qw'ssh <remotehost> bash -s') or die "Can't sta +rt ssh: $!"; print$out_fh <<EOF; <local bash script written here> EOF close $out_fh or die "Error flushing/closing pipe to ssh: $!";
see open, and Quote and Quote like Operators (watch the semicolon after <<EOF - the <<EOF syntactically stands in for the complete string)

Update:should you need variables interpolated in your 'ssh <remotehost> ...', you need to create the list in a different way, because qw doesn't interpolate variables.

Replies are listed 'Best First'.
Re^2: Pass local bash script to remote host via SSH
by haukex (Bishop) on Jun 24, 2020 at 09:43 UTC
      Good catch, updated

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2021-02-25 00:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?