#!/usr/bin/evn ruby def generate_domain_array(domain) parts = domain.split(".") l = parts.length domains = [] domains << parts.join(".") i = 0 while i < l do domains << ".#{parts[i..-1].join(".")}" i = i +1 end domains end domain = ARGV[0] domains = generate_domain_array(domain) puts "Domain Array query:" puts "SELECT * FROM squidconf.totalBlock WHERE dstdom IN ( #{domains.map { |d| "'#{d}'" }.join(" , ")} )"