Created
April 23, 2015 09:44
-
-
Save nhosoya/0b35044c0c0aa3056e2c to your computer and use it in GitHub Desktop.
Slackに通知するスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| WEBHOOKURL="$1" | |
| MESSAGEFILE=$2 | |
| CHANNEL="$3" | |
| BOTNAME="$4" | |
| FACEICON="$5" | |
| TMPFILE=$(mktemp) | |
| cat ${MESSAGEFILE} | tr '\n' '\\' | sed 's/\\/\\n/g' | sed 's/\"/\\\"/g' > ${TMPFILE} | |
| WEBMESSAGE=$(cat ${TMPFILE}) | |
| curl -s -S -X POST --data-urlencode "payload={ \ | |
| \"channel\": \"${CHANNEL}\", \ | |
| \"username\": \"${BOTNAME}\", \ | |
| \"icon_emoji\": \"${FACEICON}\", \ | |
| \"text\": \"${WEBMESSAGE}\" \ | |
| }" ${WEBHOOKURL} | |
| if [ -f "${TMPFILE}" ] ; then | |
| rm -f ${TMPFILE} | |
| fi | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment