Guest User

Untitled

a guest
Mar 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. jsonString = data.decode("utf-8")
  2.  
  3. print jsonString
  4.  
  5. {"description":"Script to check testtbeat of TEST 1 server.", "script":"#!/bin/bashnset -ennCOUNT=60 #number of 10 second timeouts in 10 minutesnSUM_SYNCS=0nSUM_SYNCS_BEHIND=0nHOSTNAME=$hostname nnwhile [[ $COUNT -ge "0" ]]; donnecho $HOSTNAMEnn#send the request, put response in variablenDATA=$(wget -O - -q -t 1 http://$HOSTNAME:8080/heartbeat)nn#grep $DATA for syncs and syncs_behindnSYNCS=$(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}')nnecho $SYNCSnecho $SYNCS_BEHINDnn#verify conditionalsnif [[ $SYNCS -gt "8" && $SYNCS_BEHIND -eq "0" ]]; then exit 0; finn#decrement the counternlet COUNT-=1nn#wait another 10 secondsnsleep 10nndonen"}
  6.  
  7. jStr = json.loads(jsonString)
  8.  
  9. ERROR Invalid control character at: line 1 column 202 (char 202)
  10.  
  11. jsonString = {"description":"Script to check testtbeat of TIER 1 server.", "script":"#!/bin/bashnset -ennCOUNT=60 #number of 10 second timeouts in 10 minutesnSUM_SYNCS=0nSUM_SYNCS_BEHIND=0nHOSTNAME=$hostname nnwhile [[ $COUNT -ge "0" ]]; donnecho $HOSTNAMEnn#send the request, put response in variablenDATA=$(wget -O - -q -t 1 http://$HOSTNAME:8080/heartbeat)nn#grep $DATA for syncs and syncs_behindnSYNCS=$(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}')nnecho $SYNCSnecho $SYNCS_BEHINDnn#verify conditionalsnif [[ $SYNCS -gt "8" && $SYNCS_BEHIND -eq "0" ]]; then exit 0; finn#decrement the counternlet COUNT-=1nn#wait another 10 secondsnsleep 10nndonen"}
  12.  
  13. print jsonString[202]
  14.  
  15. KeyError: 202
  16.  
  17. json_str = json.loads(jsonString, strict=False)
  18.  
  19. {"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"}
Add Comment
Please, Sign In to add comment