stevieb has asked for the wisdom of the Perl Monks concerning the following question:

Been a lurker since ~2k and an active member since ~2k9. Threw a question to "AI" the other day to write a script to safely allow me to update an iptables chain that I need to implement remotely. The result is below. My question for the monks isn't a question. It's a request from an old timer to see if there are any newcomers who can rewrite this script in Perl, properly.

#!/bin/sh # apply-new-iptables.sh OLD=/root/iptables-old.rules NEW=/root/iptables-new.rules # backup current iptables-save > "$OLD" # apply new rules iptables-restore < "$NEW" # start rollback timer: restore OLD after 60s if not canceled ( sleep 60 && iptables-restore < "$OLD" ) & ROLLBACK_PID=$! echo $ROLLBACK_PID > /tmp/iptables-rollback.pid echo "New rules applied. To keep them, run: kill $(cat /tmp/iptables-r +ollback.pid) && rm /tmp/iptables-rollback.pid"

Hint: there is at least one hugely fundamental issue that AI hallucinated.

-stevieb

Update: Hablo español si prefieres.

Replies are listed 'Best First'.
Re: It's been a long time
by marto (Cardinal) on Apr 08, 2026 at 11:22 UTC

    The 'task' of rewriting/correcting AI Slop isn't particularly engaging, even for a newcomer I'd suspect.

Re: It's been a long time
by LanX (Saint) on Apr 08, 2026 at 10:33 UTC
    > Update: Hablo español si prefieres.

    ¿Por qué no le pides a la IA que lo traduzca a Perl? :-)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery