#!/usr/bin/env ruby filename = ARGV[0] addressList = ARGV[1] if filename.nil? or filename.empty? STDERR.puts("Missing list filename") exit 1 end if addressList.nil? or addressList !~ /^[a-zA-Z\-\_0-9]+$/ STDERR.puts("Missing or wrong address list name") exit 2 end lines = File.open(filename).readlines template = "/ip firewall address-list" lines.each do |cidr| l = cidr.strip next if l.empty? next if l[0] == "#" template = "#{template}\nadd address=#{l} list=#{addressList}" end puts template