iainrough Posted on Jun 15, 2021 Post to Slack WebHook from Bash using Curl - Adventures in WSL2 Scripting #2 #wsl2 #bash #linux #slack #!/bin/bash # URL as supplied in your slack bot url=https://hooks.slack.com/services/{}/{}/{} #JSON body data='{"text": ":interrobang: Unable to do something"}' sendError() { curl -X \ POST \ -H 'Content-type: application/json' \ --data $data \ $url } #Function that checks something checkSomething result=$? #echo "result: $result" if [ "$result" != "0" ]; then sendError fi Enter fullscreen mode Exit fullscreen mode Bash script that on failure sends slack notice. The Result in Slack. Top comments (0) Subscribe Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)