From owner-freebsd-questions@freebsd.org Fri Mar 31 02:13:35 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 6E49ED264C5 for ; Fri, 31 Mar 2017 02:13:35 +0000 (UTC) (envelope-from ultima1252@gmail.com) Received: from mail-yw0-x235.google.com (mail-yw0-x235.google.com [IPv6:2607:f8b0:4002:c05::235]) (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 29B6A15B for ; Fri, 31 Mar 2017 02:13:35 +0000 (UTC) (envelope-from ultima1252@gmail.com) Received: by mail-yw0-x235.google.com with SMTP id i203so32705654ywc.3 for ; Thu, 30 Mar 2017 19:13:35 -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=MwIO+1zerw9tPLfkAqnStZ+UQe/VwFaxIIr+k1kXeQg=; b=O3JQqc0S2WH+M+6PRW1qXtPoJCT45vYMfFpSWI5JPn6YeA0yaQZFuqz2szeR+M9KpV Bv4KMREDCO4gLx5HWAH81Fo8h7Rl+IIkmJ4qkrwnPB4hW/3OzP6POJoS7rUlpD+O8P3p xXS6VNN9Y4Yd7KS/pfBU03QwlC9JRRTGsSbk4g2KdObkOqj0lCEMsoMWn6SMvPBzTGas pawdGOL/xjxhC25pVtZS84RsfZeNtoni2yHakWRM9ZxXKacDTvcJNwTRNCgN8TqKKeAK xV4+O3qvyQhaAJ0Ev5KHu9Jxk8lPER4Xzi7D/Kl2U0Ld4SRdQFlCwTtHnJMfuiHnnTmL pJ+w== 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=MwIO+1zerw9tPLfkAqnStZ+UQe/VwFaxIIr+k1kXeQg=; b=HZlbNbcHBx283mJEONvmS9KBRDNuk8w6QXjFWvjcD66rV3rNeLX5rbDEH3ZVonWJeD ukBhYBtvS94Nia97nA4s+cuiU+JaCT1cTGR5pLqDtVbBItSeiMozN0b0Cp3fBXShh7JK QPxpS11HLGUK10pH9mMMGVOGBXlsD9GRgfuy62gDFyoIe5DLSWoyKRzHmVuYABQD5Fpi 5oLJ6gtOzxV923eS0f3nf5w+a6DhJUa9JDlcYH3l4PBUSWjyn3RzS47lSt1dnZ8bJJ5O Af8FAf6zoX0yQZSNEb6bXo6Dk+krzV8D1zJrNrawGNz1c7MxPULNi+mp2vusH2nauZhM 4lZg== X-Gm-Message-State: AFeK/H1sPqFCF/7Ka5ksFNaVhHBDDcWER5BHWZxx4rDpgf/1uheN1FWrCYkbBN1Hy+0lDT/hjdYzr2VS6YVenw== X-Received: by 10.13.235.142 with SMTP id u136mr414870ywe.322.1490926414288; Thu, 30 Mar 2017 19:13:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.80.196 with HTTP; Thu, 30 Mar 2017 19:13:33 -0700 (PDT) In-Reply-To: References: From: Ultima Date: Thu, 30 Mar 2017 22:13:33 -0400 Message-ID: Subject: Re: shell script guru To: David Mehler Cc: 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 02:13:35 -0000 Curl is probably the correct utility for this job. With curl the cat and rm command can be negated entirely, although I'm not sure it has the same option set if explicitly required. Just stdout to the desired file. If a fresh list each use of the command is needed, add an rm before the for. On Thu, Mar 30, 2017 at 8:19 PM, William Dudley wrote: > 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" > > > _______________________________________________ > 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" >