Skip to main content
hiding ids in case they are real ones as per the suggestion in comment
Source Link

I am attempting to write a script in bash that monitors certain aspects of a server, and sends a message to slack if it notices that something is wrong. However, I am running into a strange set of error messages that leads me to believe the syntax of my script is a little off. Here is the code in question:

message=("Please go to this website: www.google.com" "Please go to this website: www.github.com" "Please go to this website: www.wikipedia.com") for j in seq `0 2`; do curl -X POST -H 'Content-type: application/json' --data '{"text":"<!channel> '${message[$j]}' "}' https://hooks.slack.com/services/KBYACJF16AN_ID/BM7AQNW69ANOTHER_ID/b6yKwxLPql8tmnCNlsnAAc9u #SOME_ID# Slack with channel mention done 

When I run this code, it should send a message to the specified slack group, stating each of the specified lines of text, for example "@channel Please go to this website: www.google.com"

When I run this, I receive the following error messages:

curl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 34 invalid_payloadcurl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 33 

Does anybody have any insights on how to resolve these error messages? I am thinking it has something to do with the way I have written the array of strings, but I can't identify the issue.

I am attempting to write a script in bash that monitors certain aspects of a server, and sends a message to slack if it notices that something is wrong. However, I am running into a strange set of error messages that leads me to believe the syntax of my script is a little off. Here is the code in question:

message=("Please go to this website: www.google.com" "Please go to this website: www.github.com" "Please go to this website: www.wikipedia.com") for j in seq `0 2`; do curl -X POST -H 'Content-type: application/json' --data '{"text":"<!channel> '${message[$j]}' "}' https://hooks.slack.com/services/KBYACJF16/BM7AQNW69/b6yKwxLPql8tmnCNlsnAAc9u # Slack with channel mention done 

When I run this code, it should send a message to the specified slack group, stating each of the specified lines of text, for example "@channel Please go to this website: www.google.com"

When I run this, I receive the following error messages:

curl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 34 invalid_payloadcurl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 33 

Does anybody have any insights on how to resolve these error messages? I am thinking it has something to do with the way I have written the array of strings, but I can't identify the issue.

I am attempting to write a script in bash that monitors certain aspects of a server, and sends a message to slack if it notices that something is wrong. However, I am running into a strange set of error messages that leads me to believe the syntax of my script is a little off. Here is the code in question:

message=("Please go to this website: www.google.com" "Please go to this website: www.github.com" "Please go to this website: www.wikipedia.com") for j in seq `0 2`; do curl -X POST -H 'Content-type: application/json' --data '{"text":"<!channel> '${message[$j]}' "}' https://hooks.slack.com/services/AN_ID/ANOTHER_ID/SOME_ID# Slack with channel mention done 

When I run this code, it should send a message to the specified slack group, stating each of the specified lines of text, for example "@channel Please go to this website: www.google.com"

When I run this, I receive the following error messages:

curl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 34 invalid_payloadcurl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 33 

Does anybody have any insights on how to resolve these error messages? I am thinking it has something to do with the way I have written the array of strings, but I can't identify the issue.

edited body
Source Link

I am attempting to write a script in bash that monitors certain aspects of a server, and sends a message to slack if it notices that something is wrong. However, I am running into a strange set of error messages that leads me to believe the syntax of my script is a little off. Here is the code in question:

message=("Please go to this website: www.google.com" "Please go to this website: www.github.com" "Please go to this website: www.wikipedia.com") for j in seq `0 2`; do curl -X POST -H 'Content-type: application/json' --data '{"text":"<!channel> '${message[$j]}' "}' https://hooks.slack.com/services/TBYACJF16KBYACJF16/BM7AQNW69/v6yKwxLPql8tmnCNlsnAAc9ub6yKwxLPql8tmnCNlsnAAc9u # Slack with channel mention done 

When I run this code, it should send a message to the specified slack group, stating each of the specified lines of text, for example "@channel Please go to this website: www.google.com"

When I run this, I receive the following error messages:

curl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 34 invalid_payloadcurl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 33 

Does anybody have any insights on how to resolve these error messages? I am thinking it has something to do with the way I have written the array of strings, but I can't identify the issue.

I am attempting to write a script in bash that monitors certain aspects of a server, and sends a message to slack if it notices that something is wrong. However, I am running into a strange set of error messages that leads me to believe the syntax of my script is a little off. Here is the code in question:

message=("Please go to this website: www.google.com" "Please go to this website: www.github.com" "Please go to this website: www.wikipedia.com") for j in seq `0 2`; do curl -X POST -H 'Content-type: application/json' --data '{"text":"<!channel> '${message[$j]}' "}' https://hooks.slack.com/services/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 # Slack with channel mention done 

When I run this code, it should send a message to the specified slack group, stating each of the specified lines of text, for example "@channel Please go to this website: www.google.com"

When I run this, I receive the following error messages:

curl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 34 invalid_payloadcurl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 33 

Does anybody have any insights on how to resolve these error messages? I am thinking it has something to do with the way I have written the array of strings, but I can't identify the issue.

I am attempting to write a script in bash that monitors certain aspects of a server, and sends a message to slack if it notices that something is wrong. However, I am running into a strange set of error messages that leads me to believe the syntax of my script is a little off. Here is the code in question:

message=("Please go to this website: www.google.com" "Please go to this website: www.github.com" "Please go to this website: www.wikipedia.com") for j in seq `0 2`; do curl -X POST -H 'Content-type: application/json' --data '{"text":"<!channel> '${message[$j]}' "}' https://hooks.slack.com/services/KBYACJF16/BM7AQNW69/b6yKwxLPql8tmnCNlsnAAc9u # Slack with channel mention done 

When I run this code, it should send a message to the specified slack group, stating each of the specified lines of text, for example "@channel Please go to this website: www.google.com"

When I run this, I receive the following error messages:

curl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 34 invalid_payloadcurl: (6) Could not resolve host: go curl: (6) Could not resolve host: to curl: (6) Could not resolve host: this curl: (6) Could not resolve host: website: curl: (3) [globbing] unmatched close brace/bracket in column 33 

Does anybody have any insights on how to resolve these error messages? I am thinking it has something to do with the way I have written the array of strings, but I can't identify the issue.

edited title
Link

Using an array of strings with spaces in bash - error messages "curl: could not resolve host"

Source Link
Loading