Skip to content

Instantly share code, notes, and snippets.

@gemmadlou
Forked from rikwatson/tailSlack.sh
Created May 4, 2019 18:58
Show Gist options
  • Select an option

  • Save gemmadlou/d1cd0bcf11400e15c823dbfd5c5aa2ab to your computer and use it in GitHub Desktop.

Select an option

Save gemmadlou/d1cd0bcf11400e15c823dbfd5c5aa2ab to your computer and use it in GitHub Desktop.
Stream any log file to Slack using curl
#!/bin/bash
tail -n0 -F "$1" | while read LINE; do
(echo "$LINE" | grep -e "$3") && curl -X POST --silent --data-urlencode \
"payload={\"text\": \"$(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