[TUHS] Remember the ed thread?

Larry McVoy lm at mcvoy.com
Tue Mar 30 00:34:49 AEST 2021

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

        FILE    log = popen("/var/log/apache2/dns.l", "r");
        string  buf, ip;
	string	dropped{string};

	fconfigure(log, buffering: "line");
        while (buf = <log>) {
                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");

More information about the TUHS mailing list