Created
April 21, 2025 03:20
-
-
Save huynhbaoan/076f59daa2635d64df5c182f59e5c103 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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