in reply to Monitoring a firewall using ssh (was: Is this possible in Perl?)

well, part one should be easy with the aforementioned modules, and for part two you would just have to change the relevant files (/etc/hostname.hmeX, /etc/hosts, /etc/netmasks on solaris; /etc/sysconfig/network, /etc/resolv.conf, /etc/sysconfig/network-scripts/ifcfg-ethX for linux) and restart the network, this can be done in very few lines using perl -i to edit these files and restart the network.
#!perl -i @ARGV = ("/etc/hosts"); while(<>){ s/OLDIP/NEWIP; # change the ip s/OLDHOSTNAME/NEWHOSTNAME; # change the hostname print; } # repeat a while loop like this for all of the network files.
Hope this helps. -malloc

Replies are listed 'Best First'.
Re: Re: Is this possible in Perl?
by Vynce (Friar) on May 30, 2001 at 01:07 UTC

    you're missing some slashes there.

    s/OLDIP/NEWIP/; s/OLDHOSTNAME/NEWHOSTNAME/;
    mmm, untested perl code...