0

I'm on OpenWRT (which uses BusyBox).

When I run this script:

 while read oldIP ; do
    iptables -t nat -D PREROUTING --dst $oldIP -p tcp --dport 443 -j DNAT --to 192.168.2.1:443
 done < <(comm -23 <(sort /tmp/currentIPs) <(sort /tmp/newIPs))

I get this error:

 syntax error: unexpected redirection 

I believe that it doesn't like the "<(" part. So, my question is...How can I change this script so that BusyBox will like it?

chepner
  • 497,756
  • 71
  • 530
  • 681
exvance
  • 1,339
  • 4
  • 13
  • 31

1 Answers1

2

The "<()" is called process substitution, and is a bash-specific feature. You need to use temporary files and a pipeline for it work on other POSIX shells.

sort /tmp/currentIPs > /tmp/currentIPs.sorted
sort /tmp/newIPs > /tmp/newIPs.sorted
comm -23 /tmp/currentIPs.sorted /tmp/newIPs.sorted | while read oldIP ; do
    iptables -t nat -D PREROUTING --dst $oldIP -p tcp --dport 443 -j DNAT --to 192.168.2.1:443
done
rm /tmp/currentIPs.sorted /tmp/newIPs.sorted
jordanm
  • 33,009
  • 7
  • 61
  • 76