Skip to content

Instantly share code, notes, and snippets.

@Rvolvr
Created November 18, 2021 17:43
Show Gist options
  • Save Rvolvr/0f755f32a96e913b4e7b2b975159eca6 to your computer and use it in GitHub Desktop.
Save Rvolvr/0f755f32a96e913b4e7b2b975159eca6 to your computer and use it in GitHub Desktop.
Discord Webhook Logs
#!/bin/bash
# Use: ./log-to-discord.sh <LogFilePath> <DiscordWebHook> <LogKeyword>
tail -n0 -F "$1" | while read LINE; do
(echo "$LINE" | grep -e "$3") && curl -X POST --silent -H "Content-Type:application/json" \
--data "{\"content\": \"$(echo $LINE | sed "s/\"/'/g")\"}" "$2";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment