[TUHS] Remember the ed thread?
Rob Pike
robpike at gmail.com
Tue Mar 30 05:50:10 AEST 2021
Ed is the standard editor.
-rob
On Tue, Mar 30, 2021 at 1:36 AM Larry McVoy <lm at mcvoy.com> 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 = <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");
> }
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20210330/a070bbc2/attachment.htm>
More information about the TUHS
mailing list