Re: Prosze o opinie o exatel-u

Autor: Piotr KUCHARSKI <chopin_at_sgh.waw.pl>
Data: Tue 22 May 2007 - 20:30:53 MET DST
Message-ID: <eT4421mvIpqeN34.chopin@akson.sgh.waw.pl>
Content-Type: text/plain; charset=ISO-8859-2

Lukasz Trabinski <lukasz@trabinski.nospam.net> wrote:
> for a in `peval as5617`;
> do iptables -A FORWARD -s 0/0 -d `echo $a|
> sed s/","/""/g|sed s/"{"/""/g|sed s/"}"/""/g|sed s/")"/""/g|
> sed s/"("/""/g` -j ACCEPT ;done
> pewnie tego seda też dałoby się jakoś skrócić...

Choćby tak:
for a in `peval as5617`
 do iptables -A FORWARD -s 0/0 -d `echo $a|sed "s/,//g;s/{//g;s/}//g;s/)//g;s/(//g"` -j ACCEPT
done

A lepiej:
for a in `peval as5617`
 do iptables -A FORWARD -s 0/0 -d `echo $a|sed "s/[,{})(]//g"` -j ACCEPT
done

A jeszcze lepiej:
for a in `peval as5617 | sed "s/[,{})(]//g"`
 do iptables -A FORWARD -s 0/0 -d $a -j ACCEPT
done

A skoro tylko tniemy, to
for a in `peval as5617 | tr -d '[,{}()]'`; do
  iptables -A FORWARD -s 0/0 -d $a -j ACCEPT
done

Albo ciut inaczej, bez backticków i fora:

peval as5617 | tr -d '[,{}()]' | fmt -1 | \
xargs -I{} iptables -A FORWARD -s 0/0 -d {} -j ACCEPT

p.

PS peval daje duplikaty, np.: 217.96.0.0/14, 217.96.0.0/16,
   217.97.0.0/16, 217.98.0.0/16, 217.99.0.0/16

-- 
Beware of he who would deny you access to information, for in his
heart he dreams himself your master.   -- Commissioner Pravin Lal
Received on Tue May 22 20:35:07 2007

To archiwum zostało wygenerowane przez hypermail 2.1.8 : Tue 22 May 2007 - 20:40:01 MET DST