#!/usr/bin/perl


# Script to login to work machine and rewrite /$home/etc/hosts entry #there

use strict;
use warnings;

Excellent!


use Net::SSH qw(sshopen2);


my $ppp0 = `/sbin/ifconfig ppp0`; $ppp0 =~ m/(\d+\.\d+\.\d+\.\d+)/; my $ip = $1;



my $user = "jrak";
my $host = "mail.myhost.org";
my $cmd = "perl -pi -e 's/^\\d+\\.\\d+\\.\\d+\\.\\d+\thome/$ip\thome/' /home/jrak/etc/hosts";





sshopen2("[EMAIL PROTECTED]", *READER, *WRITER, "$cmd") || die "ssh: $!";

or die may be better.. but its awesome you're die()ing!

while (<READER>) {
        chomp();
        print "$_\n";

Only thing, and its not a big deal since this is likley just test code but: Why chomp() if you're just adding back a \n?

 while(<READER>) { print }
would do the same thing as that pretty much.

        }

                                                       close(READER);
close(WRITER);



/home/jrak/etc/hosts file is always like this:
192.168.1.1    home

Thanks for any input you have,

It looks nice Jeff, you die, use strict and warnings - very very very good way to begin perl!


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to