iterating over a list and printing

From: Bart Nessux (bart_nessux_at_hotmail.com)
Date: 02/11/04


Date: Wed, 11 Feb 2004 10:24:14 -0500

ip_list = []
inputFile = file('ips.txt', 'r')
ip_list.append(inputFile.read())
inputFile.close()
for i in ip_list:
    print "/sbin/ifconfig %s netmask 255.255.252.0 broadcast
128.173.123.255 up" %i

The last line does not work. It prints the first part (/sbin/ifconfig),
then the entire list of ips, then the second part (netmask 255.255.252.0
broadcast 128.173.123.255 up). Any ideas on how to fix this? The desired
results are to print a line for each IP.

/sbin/ifconfig IP1 netmask 255.255.252.0 broadcast 128.173.123.255 up
/sbin/ifconfig IP2 netmask 255.255.252.0 broadcast 128.173.123.255 up
etc...



Relevant Pages

  • search & replace from input file
    ... I have a input file and want to create an output file that contains ... the converted digit we find in inputfile. ... Can you help me fix the ...
    (comp.lang.perl.misc)
  • Re: search & replace from input file
    ... the converted digit we find in inputfile. ... Can you help me fix the script? ...
    (comp.lang.perl.misc)