Last active
August 23, 2023 19:30
-
-
Save h0tw1r3/c98122b732ecbee6b8bbda8e403b2e34 to your computer and use it in GitHub Desktop.
continuously log random meat ipsum to syslog using logger
This file contains 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
#!/bin/bash | |
TMPFILE=$(mktemp) | |
finish() { | |
rm -f "${TMPFILE}" | |
} | |
trap 'finish' EXIT | |
UNIQ_LINES=20 | |
if curl -sSL -o "${TMPFILE}" "https://baconipsum.com/api/?type=all-meat¶s=$((UNIQ_LINES+1))&format=text" ; then | |
I=0 | |
while IFS= read -r line ; do | |
if [ -n "$line" ] ; then | |
let "I++" | |
declare "LOG_${I}"="$line" | |
fi | |
done < <("${TMPFILE}") | |
I=0 | |
while true ; do | |
let "I++" | |
LOG="LOG_$(( ( RANDOM % 19 ) + 1 ))" | |
echo "${!LOG} ${I}" | |
(( I % UNIQ_LINES == 0 )) && sleep 0.25 | |
done | logger --tag loggertest | |
else | |
echo 'failed to download sample messsages' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment