擅长:python、mysql、java
<p><a href="https://stackoverflow.com/a/42073/116047">Escape your newlines.</a></p>
<pre><code>{"description":"Script to check testtbeat of TEST 1 server.", "script":"#!/bin/bash\\nset -e\\n\\nCOUNT=60 #number of 10 second timeouts in 10 minutes\\nSUM_SYNCS=0\\nSUM_SYNCS_BEHIND=0\\nHOSTNAME=$hostname #dc1dbx1145.dc1.host.com\\n\\nwhile [[ $COUNT -ge \\"0\\" ]]; do\\n\\necho $HOSTNAME\\n\\n#send the request, put response in variable\\nDATA=$(wget -O - -q -t 1 http://$HOSTNAME:8080/heartbeat)\\n\\n#grep $DATA for syncs and syncs_behind\\nSYNCS=$(echo $DATA | grep -oE 'num_syncs: [0-9]+' | awk '{print $2}')\\nSYNCS_BEHIND=$(echo $DATA | grep -oE 'num_syncs_behind: [0-9]+' | awk '{print $2}')\\n\\necho $SYNCS\\necho $SYNCS_BEHIND\\n\\n#verify conditionals\\nif [[ $SYNCS -gt \\"8\\" && $SYNCS_BEHIND -eq \\"0\\" ]]; then exit 0; fi\\n\\n#decrement the counter\\nlet COUNT-=1\\n\\n#wait another 10 seconds\\nsleep 10\\n\\ndone\\n"}
</code></pre>
<p>对我有用。</p>
<p>另外,如果以后遇到这样的错误,可以使用一种调试技术,将字符串缩短为可以工作的字符串,然后缓慢地添加数据,直到它不工作为止</p>