Ed is the standard editor. -rob On Tue, Mar 30, 2021 at 1:36 AM Larry McVoy wrote: > I had *.clients.your-server.de crawling mcvoy.com in violation of my > robots.txt. For whatever reason, the tty settings (or something) > made vi not work, I dunno what the deal is, stty -tabs didn't help. > > So I had to resort to ed to write and debug the little program below. > It was surprisingly pleasant, it's probably the first time I've used ed > for anything real in at least a decade. My fingers still know it. > > +1 for ed. It's how many decades old and still useful? > > > #!/usr/libexec/bitkeeper/bk tclsh > > int > main(void) > { > FILE log = popen("/var/log/apache2/dns.l", "r"); > string buf, ip; > string dropped{string}; > > fconfigure(log, buffering: "line"); > while (buf = ) { > unless (buf =~ /([^ ]+\.your-server\.de\.) /) continue; > ip = $1; > if (defined(dropped{ip})) continue; > dropped{ip} = "yes"; > warn("DROP ${ip}\n"); > system("/sbin/iptables -I INPUT -s ${ip} -j DROP"); > } > } >