Skip to content

Instantly share code, notes, and snippets.

@elit69
Last active March 27, 2019 06:06
Show Gist options
  • Save elit69/00486e5da8862107fc1f02fda513f8b2 to your computer and use it in GitHub Desktop.
Save elit69/00486e5da8862107fc1f02fda513f8b2 to your computer and use it in GitHub Desktop.
# wget https://gist.githubusercontent.com/elit69/00486e5da8862107fc1f02fda513f8b2/raw/a0d8714f33eb28596af5fcec23d1b81604bff366/watch.sh
# chmod +xr watch.sh
# ./watch.sh '' '' '' '' > watch.log &
# $1 = *.log
# $2 = pattern1
# $3 = pattern2
# $4 = web hook end point
tail -Fn0 $1 | \
while read line ; do
echo $line | grep "$2" | grep "$3"
if [ $? = 0 ]
then
line=${line//\"/\\\"}
printf -v json -- '{ "text": "%s"}' "$line"
curl --request POST --url $4 --header 'content-type: application/json' --data "$json"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment