Skip to content

Instantly share code, notes, and snippets.

@JoeyBurzynski
Forked from amberovsky/slack.sh
Created May 1, 2016 18:41
Show Gist options
  • Save JoeyBurzynski/d279d3ec18595dde83613ec7b5094432 to your computer and use it in GitHub Desktop.
Save JoeyBurzynski/d279d3ec18595dde83613ec7b5094432 to your computer and use it in GitHub Desktop.
Slack incoming webhooks from bash (send notification to slack from shell)
read -d '' SLACK_PAYLOAD_DATA << EOF
{
"channel": "#channel",
"username": "Bot",
"text": "Message by _$(id -un)@$(hostname -f)_.",
"icon_emoji": ":poop:",
"attachments": [
{
"fields": [
{
"title": "User",
"value": "$(id -un)",
"short": true
},
{
"title": "Host",
"value": "$(hostname -f)",
"short": true
}
]
}
]
}
EOF
SLACK_COMMAND="curl -X POST --data-urlencode 'payload=${SLACK_PAYLOAD_DATA}' https://hooks.slack.com/services/XXX/QQQ/WWW"
eval ${SLACK_COMMAND}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment