2 # vim: set et sw=4 sts=4 :
6 for c in line.split('\t'):
7 r.append(c.strip('"\n'))
14 if line.startswith('"tabla de ruteo de '):
18 hosts[host]['ifaces'] = []
19 while line and line.strip() <> '"red"\t"ip"\t"mascara"\t"gateway"\t"interfaz"\t"metrica"':
20 if line.startswith('"'):
21 (iface, ip, mascara, broadcast) = get_campos(line)[:4]
22 hosts[host]['ifaces'].append({
26 'broadcast': broadcast,
30 hosts[host]['rutas'] = []
31 while line and line.strip() <> '"--"':
32 if line.startswith('"'):
33 (red, ip, mascara, gateway, iface, metrica) = get_campos(line)
34 if not metrica: metrica = "1"
35 hosts[host]['rutas'].append({
49 #pprint.pprint(parse(sys.stdin))
51 hosts = parse(sys.stdin)
52 for iface in hosts[host]['ifaces']:
53 if not iface['iface'].startswith('ppp'):
54 print 'ifconfig %(iface)s %(ip)s broadcast %(broadcast)s netmask %(mascara)s' % iface
55 for ruta in hosts[host]['rutas']:
56 if ruta['metrica'] <> "0":
57 print 'route add -net %(ip)s gw %(gateway)s netmask %(mascara)s dev %(iface)s metric %(metrica)s' % ruta
59 if __name__ == '__main__':