Skip to content

Instantly share code, notes, and snippets.

@brycesch
Last active April 8, 2021 17:40
Show Gist options
  • Select an option

  • Save brycesch/ea041a2794f51f89c980663fbf1a3a7a to your computer and use it in GitHub Desktop.

Select an option

Save brycesch/ea041a2794f51f89c980663fbf1a3a7a to your computer and use it in GitHub Desktop.
tail file to webhook endpoint
#!/bin/bash
# chmod a+x tails.sh
# nohup ./tails.sh foobar.log webhook_url &
# use nohup if you want the cammand to persist after your session ends
#
# slack
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
#!/bin/bash
# chmod a+x tails.sh
# nohup ./tails.sh foobar.log webhook_url &
# use nohup if you want the cammand to persist after your session ends
#
# msteams
tail -n0 -F "$1" | while read LINE; do
(echo "$LINE" | grep -e "$3") && curl -H "Content-Type: application/json" -d "{\"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