perl -> ssh?

Keary Suska aksuska at webflyer.com
Mon Sep 10 18:20:25 CDT 2001


IIRC, the second part of the ssh invocation is the command to execute on the
remote machine, so you could do:

$host_str = join( "\n", @Array);
`ssh host echo "$host_str" > /etc/hosts`;

Otherwise you would have to use SCP in SSH2 or interact with ssh as a tty.
IO::Pty or Expect modules from CPAN might help.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

> From: "Robert L. Harris" <Robert.L.Harris at rdlg.net>
> Date: Mon, 10 Sep 2001 15:21:23 -0600
> To: Pikes-Peak Perl Mongers <pikes-peak-pm-list at happyfunball.pm.org>
> Subject: perl -> ssh?
> 
> 
> 
> I'm working on a script and in the pre-planning process hit some walls.
> I can do a "ssh $host cat /etc/hosts" and read the input into an array.  I
> then want to modify the array and write /etc/hosts back out on $host.
> 
> What's a good way to do this?
> 
> print @Array `ssh host > /etc/hosts` doesn't seem a good idea or to work
> for that matter.
> 
> Thoughts?
> 
> 
> :wq!
> ---------------------------------------------------------------------------
> Robert L. Harris                |  Micros~1 :
> Senior System Engineer          |    For when quality, reliability
> at RnD Consulting             |      and security just aren't
> \_       that important!
> DISCLAIMER:
> These are MY OPINIONS ALONE.  I speak for no-one else.
> FYI:
> perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
> 
> 




More information about the Pikes-peak-pm mailing list