shell script guru

Ultima ultima1252 at gmail.com
Fri Mar 31 02:13:35 UTC 2017


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 <wfdudley at gmail.com> 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 <dave.mehler at gmail.com>
> 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 <r.rajamani at gmail.com> wrote:
> > > Ask your question and I am sure someone will answer!
> > >
> > > On Mar 30, 2017 7:37 PM, "David Mehler" <dave.mehler at gmail.com> 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 at freebsd.org mailing list
> > >> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > >> To unsubscribe, send any mail to "freebsd-questions-
> > >> unsubscribe at freebsd.org"
> > >>
> > >
> > _______________________________________________
> > freebsd-questions at freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to "freebsd-questions-
> > unsubscribe at freebsd.org"
> >
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-
> unsubscribe at freebsd.org"
>


More information about the freebsd-questions mailing list