So I am trying to create a script that will send data to a slack hook app. This is my current code:
DATA="[app_code: app_code | error invalid _id: alsdjasdlkj];[app_code: app_code | error invalid _type: 1a1]"
IFS=';' ;read -ra errors <<< "$DATA"
unset IFS
cmd=$(curl -X POST -H 'Content-type: application/json' --data '{"text": "'"${errors[@]}"'" }' hook_url)
echo $cmd
The issue I am having is that I want to send an array list of errors as I will never know how many there could be at any given time. when I run this bash command this is the error I get:
curl: (3) bad range in URL position 2:
[app_code: app_code | error invalid _type: 1a1]" }
So how can I fix the code to send an array as a curl command for the data field? And if that's not possible is there a workaround for this? I need the text to show up on the slack channel as follows:
Total errors: 2
[app_code: app_code | error invalid _id: alsdjasdlkj]
[app_code: app_code | error invalid _type: 1a1]
Any help is appreciated. Thanks!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…