Last active
March 16, 2017 13:45
-
-
Save gouf/0b16e3cc818d87fc04a9d3024e46fe5c to your computer and use it in GitHub Desktop.
Notify command execution result to Slack (Incoming Webhooks)
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/sh | |
| WORK_DIR="/where/to/work/directory" | |
| cd $WORK_DIR || exit # In crontab, it may needs moving into work directory from default directory (home directory) | |
| LS_FILES="$(ls -l file*)" # Wants notify this result | |
| notifyToSlack() { | |
| # In crontab, make sure to the curl command (or other commands) is full path. | |
| /usr/bin/curl -X POST -H 'Content-type: application/json' \ | |
| --data "$1" \ | |
| https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX | |
| } | |
| notifyToSlack "{\"text\": \"\`\`\`\n$LS_FILES\n\`\`\`\"}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment