Issue
I was following this link to stream data from mysql to kafka topic in my ubuntu machine. There, in Kafka Connect setup topic, when I run to check if my connectors are running with this(as suggested there):
curl -s "http://localhost:8083/connectors" | jq '.[]' | xargs -I mysql-connector curl -s "http://localhost:8083/connectors/mysql-connector/status" | jq -c -M '[.name,.connector.state,.tasks[].state] | \
join(":|:")'| column -s : -t| sed 's/\"//g'| sort
I got this error:
jq: error: syntax error, unexpected INVALID_CHARACTER (Unix shell quoting issues?) at , line 1: [.name,.connector.state,.tasks[].state] | \
jq: 1 compile error (23) Failed writing body (23) Failed writing body
I am totally stuck. Anyone please help if possible.
N.B.: This is not duplicate question, though question with similar headline exists but problem is different and I have checked them well.
Solution
You are abusing \
. Use:
curl -s "http://localhost:8083/connectors" |
jq '.[]' |
xargs -I mysql-connector curl -s "http://localhost:8083/connectors/mysql-connector/status" |
jq -c -M '[.name,.connector.state,.tasks[].state] |
join(":|:")' |
column -s : -t |
tr -d \" |
sort
It might be cleaner to put the jq
all on one line, but the key point is that if you try to escape the newline inside single quotes, you end up with a literal backslash in the jq
command that does not belong there.
Answered By - William Pursell