This is much more a shell question than a Perl question, but as Perl file operators are quite similar to shell file operators, it's still valid..
To append to a file, use >> (or open my $fh, '>>', ... ) instead of > alone.
On the other hand, the pipe character is used for output piping in the shell, but is a logic operator in Perl. So print | $fh does not work. The syntax for printing to a filehandle is print { $fh } $string;, see also print.
You don't show what SSH module you're using, so I'll assume Net::OpenSSH:
my $cmd = "cat >> /home/vmsys/.ssh/authorized_keys"; my ($stdin, $stdout,$stderr,$pid) = $ssh->open_ex("$cmd"); print { $stdin } $mypubcert;
In reply to Re: Net::SSH::Perl push variable into remote file
by Corion
in thread Net::SSH::Perl push variable into remote file
by rtech0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |