curl -X POST --data-urlencode "payload={'channel': '#general', 'username': 'webhookbot', 'text': \"$(wc -l ips.txt | awk '{print $1}')\", 'icon_emoji': ':ghost:'}" https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx
eu tenho abaixo do Código.
curl -X POST --data-urlencode 'payload={"channel": "#general", "username": "webhookbot", "text": "This is posted to #general and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx
este comando envia This is posted to #general and comes from a bot named webhookbot
para Slack Channel
, agora eu quero substituir Isto com a saída de
wc -l ips.txt | awk '{print $1}'
eu quero isso:
curl -X POST --data-urlencode 'payload={"channel": "#general", "username": "webhookbot", "text": "OUTPUT OF wc -l command , like number 154", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx
Como posso fazer isso?
Você deve poder usar backticks para expansão de comando:
curl -X POST --data-urlencode 'payload={"channel": "#general", "username": "webhookbot", "text": "'wc -l ips.txt | awk '{print $1}''", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx
Tags stdout awk slackware stdin slackbuilds