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.
In reply to It's been a long time by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |