Skip to content

Instantly share code, notes, and snippets.

@huynhbaoan
Created April 21, 2025 03:20
Show Gist options
  • Save huynhbaoan/076f59daa2635d64df5c182f59e5c103 to your computer and use it in GitHub Desktop.
Save huynhbaoan/076f59daa2635d64df5c182f59e5c103 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
# 1) initialize/clear per‑profile logs
awk -F, '
NR>1 { logs[$1]=1 }
END { for(p in logs) system("> " p "-output.log") }
' ips.csv
# 2) for each line (skip header) in ips.csv
tail -n +2 ips.csv | while IFS=, read -r profile ip; do
log="${profile}-output.log"
echo "---- IP: $ip ----" >>"$log"
export AWS_PROFILE=$profile
# 3) run the lookup, but never exit the loop on error
if ! ./runscript.sh "$ip" >>"$log" 2>&1; then
echo "⚠️ runscript.sh failed for IP $ip" >>"$log"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment