From owner-freebsd-questions@freebsd.org Fri Mar 31 00:19:17 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D35ED22679 for ; Fri, 31 Mar 2017 00:19:17 +0000 (UTC) (envelope-from wfdudley@gmail.com) Received: from mail-yw0-x22b.google.com (mail-yw0-x22b.google.com [IPv6:2607:f8b0:4002:c05::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52E80E3F for ; Fri, 31 Mar 2017 00:19:17 +0000 (UTC) (envelope-from wfdudley@gmail.com) Received: by mail-yw0-x22b.google.com with SMTP id d191so31867208ywe.2 for ; Thu, 30 Mar 2017 17:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=BW14Wvf227mz8bwFJfUDFec8SD1DO35M556Ss+Wv9mo=; b=AkE6mJdtag4uQbWrP0biOG3E/KngEgnS+pPI6DSv4jnIfMiLFlTkMKU6FXmiwY19HK cvVor8Y4j4ziHESKivCebfBwvl7nkbZjBtNEB8ulTJQ5g7dzVhHTotvf2c9WuT/cTg2u i4SSYSfAb3yOHdwP5Nbo6cnSDKYY4mE3KC9yg5D2+RVYsPHo80SWg72+bb8Rm1roWcdS M6WG1NQJByC/Qcy818z6E2cOJQJmF7B3H2tH2AmLXAEzlANsrzsM5VFcLbqo51i+SjZ8 y3OVO25heAmNTQZHo9CDBLg+1BXVHNdTdAEBYyJiiGxt+KtD6s4M4tb9zmsUMPNeWEIF 20zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BW14Wvf227mz8bwFJfUDFec8SD1DO35M556Ss+Wv9mo=; b=UnX7UA/ii5l4yj+ficXQIkrGkLzZYIE3KKKxmL6Lch5ReG2CvGwfogYbZZ993TMvXN mKTLo6To6IQ3FZaIe1FJgfo7TtXqDL+1uGwGpep96Japhgh/VqWcdG+c7OJmFbKuk3wn 82Fgx0nyKwWqTMF8KbtEdV7mSwgspnd4c/ObVAs5C4nlAmvD8TJyESuxRzzQ8GvLC7xg fNakAzlRuFDdEzOOrAQ5DWl0Tlb7UumZ6dr7ssVCTL2r1N3lWXueL5aJWmWO0KjPqXSe 8jO6gbmJgOrdIA4SLCpI2xVk2zxduagdBC4O9ZkPwq/3z0ALUIb0Zb5DIvG8rrIdFB5V Y6TA== X-Gm-Message-State: AFeK/H1SP2mA4zwMFtKkqgrOs2fypY7ZJkhUnWDjdkxZkpE22nfRIQT8ZErfwkjtxXZWLtXOuZT/ByY0b0wkpA== X-Received: by 10.129.55.129 with SMTP id e123mr98582ywa.251.1490919556305; Thu, 30 Mar 2017 17:19:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.163.227 with HTTP; Thu, 30 Mar 2017 17:19:15 -0700 (PDT) In-Reply-To: References: From: William Dudley Date: Thu, 30 Mar 2017 20:19:15 -0400 Message-ID: Subject: Re: shell script guru To: David Mehler Cc: Rajarajan Rajamani , freebsd-questions Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2017 00:19:17 -0000 for i in "vn.zone" "uz.zone" "tm.zone" ; do wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/$i cat $i >>blocked_zones rm $i sleep 2 done Like that? Bill This email is free of malware because I run Linux. On Thu, Mar 30, 2017 at 8:02 PM, David Mehler wrote: > Hello, > > My question is regarding a shell script and pf. > > What I'm wanting to do is take a selected list of countries and cat > them in to a file and use that as pf input. Here's a sequential > example: > > #!/bin/sh > # > PATH=/bin:/usr/local/bin:/sbin > cd /tmp > mkdir zones > cd zones > # -4 = use IPv4 only > # --no-proxy = don't care for proxies > # --no-cookies = don't accept cookies > # --no-cache = no cached files > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/cn.zone # CHINA > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/az.zone # AZERBAIJAN > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/by.zone # BELARUS > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/kz.zone # KAZAKHSTAN > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/kg.zone # KYRGYZSTAN > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/ru.zone # RUSSIAN > FEDERATION > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/tj.zone # TAJIKISTAN > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/tm.zone # TURKMENISTAN > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/uz.zone # UZBEKISTAN > sleep 2 > wget -4 --no-proxy --no-cookies --no-cache \ > http://ipdeny.com/ipblocks/data/countries/vn.zone # VIET NAM > # > cat cn.zone > blocked_zones > cat az.zone >> blocked_zones > cat by.zone >> blocked_zones > cat kz.zone >> blocked_zones > cat kg.zone >> blocked_zones > cat ru.zone >> blocked_zones > cat tj.zone >> blocked_zones > cat tm.zone >> blocked_zones > cat uz.zone >> blocked_zones > cat vn.zone >> blocked_zones > # > rm *.zone > # > mv blocked_zones /etc/pf/ > pfctl -f /etc/pf.conf > > There are 250 plus zones just in the ipv4 space, and about the same in > the ipv6 space. I do not want to manually take down each domain, three > times, that's error prown and very easy to miss one. I thought about > doing an array, and feeding that to a loop which would cut down the > number of lines of repeative code. > > Help appreciated. > > Thanks. > Dave. > > > On 3/30/17, Rajarajan Rajamani wrote: > > Ask your question and I am sure someone will answer! > > > > On Mar 30, 2017 7:37 PM, "David Mehler" wrote: > > > >> Hello, > >> > >> Any shell scripting gurus here please contact me offlist. I have a > >> question that I can't figure out. > >> > >> Thanks. > >> Dave. > >> _______________________________________________ > >> freebsd-questions@freebsd.org mailing list > >> https://lists.freebsd.org/mailman/listinfo/freebsd-questions > >> To unsubscribe, send any mail to "freebsd-questions- > >> unsubscribe@freebsd.org" > >> > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions- > unsubscribe@freebsd.org" >