in reply to Pass local bash script to remote host via SSH
see open, and Quote and Quote like Operators (watch the semicolon after <<EOF - the <<EOF syntactically stands in for the complete string)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: $!";
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
by soonix (Canon) on Jun 24, 2020 at 10:06 UTC