send slack message from command line
Install Incomming webhook to your channel https://api.slack.com/incoming-webhooks#sending_messages​
you will then get some url https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
create /usr/local/bin/notifyme
1
#!/bin/sh
2
​
3
curl -X POST --data-urlencode "payload={\"channel\": \"#alert\", \"username\": \"mybot\", \"text\": \"$*\", \"icon_emoji\": \":name_badge:\"}" https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Copied!
and send message via your command line
1
$ chmod +x /usr/local/bin/notifyme
2
$ notifyme hello world!
3
​
4
# or after some command
5
$ sleep 5; notifyme process is finished
Copied!
Last modified 1mo ago
Copy link