Skip to content

Instantly share code, notes, and snippets.

@h0tw1r3
Last active August 23, 2023 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h0tw1r3/c98122b732ecbee6b8bbda8e403b2e34 to your computer and use it in GitHub Desktop.
Save h0tw1r3/c98122b732ecbee6b8bbda8e403b2e34 to your computer and use it in GitHub Desktop.
continuously log random meat ipsum to syslog using logger
#!/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&paras=$((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