Skip to content

Instantly share code, notes, and snippets.

@craig-m
Created November 27, 2018 02:47
Show Gist options
  • Select an option

  • Save craig-m/4b45a48749c456ae76d982a812042e93 to your computer and use it in GitHub Desktop.

Select an option

Save craig-m/4b45a48749c456ae76d982a812042e93 to your computer and use it in GitHub Desktop.
tail a file and post to a slack chan
#!/bin/bash
tail -n0 -F "/var/log/mpdscribble/play.log" | while read LINE; do
(echo "$LINE" | grep -e "$3") && curl -X POST --silent --data-urlencode \
"payload={\"channel\": \"#mp3-play\", \"username\": \"my-jukebox\", \"icon_emoji\": \":speaker:\",\"text\": \"$(echo $LINE | cut -d " " -f2- | sed "s/\"/'/g")\"}" "https://hooks.slack.com/services/zz/zz/zz";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment