#!/usr/bin/perl # Created by Ben Okopnik on Mon Dec 22 22:13:11 EST 2003 use warnings; use strict; my ( $ans, %loc ); $loc{IP} = "10.28.4.20"; $loc{netmask} = "255.255.255.0"; $loc{resolver1} = "216.240.40.162"; $loc{resolver2} = "216.240.40.163"; $loc{gateway} = "10.28.4.130"; for my $var ( sort keys %loc ){ print "What is the $var? (default: $loc{$var}) "; chomp( $ans = ); if ( $ans =~ /\d+(?:\.\d+){3}/ ){ local ( $^I, $ARGV[0] ) = ( '', $0 ); while ( <> ){ s/^(\$loc{$var} = ").*(";)$/$1$ans$2/; print; } } } print <<`ShellOut` ifconfig eth0 $loc{IP} netmask $loc{netmask} echo "nameserver $loc{resolver1}" > /etc/resolv.conf echo "nameserver $loc{resolver2}" >> /etc/resolv.conf route add default gw $loc{gateway} ShellOut