[{"data":1,"prerenderedAt":562},["ShallowReactive",2],{"post:toggle-debug-mode":3},{"id":4,"title":5,"body":6,"date":552,"description":12,"draft":553,"extension":554,"meta":555,"navigation":69,"path":556,"seo":557,"stem":558,"tags":559,"__hash__":561},"posts\u002Fposts\u002Ftoggle-debug-mode.md","TIL: Toggle Debug Mode",{"type":7,"value":8,"toc":550},"minimark",[9,13,16,53,60,181,184,235,263,383,386,543,546],[10,11,12],"p",{},"Doing a big (ok, small) script to check for SSL certificates on a list of about 200 of our client websites.",[10,14,15],{},"Something like:",[17,18,23],"pre",{"className":19,"code":20,"language":21,"meta":22,"style":22},"language-bash shiki shiki-themes github-light github-dark","cat our-client-domain-list.md | xargs -n1 sslcheck\n","bash","",[24,25,26],"code",{"__ignoreMap":22},[27,28,31,35,39,43,46,50],"span",{"class":29,"line":30},"line",1,[27,32,34],{"class":33},"sScJk","cat",[27,36,38],{"class":37},"sZZnC"," our-client-domain-list.md",[27,40,42],{"class":41},"szBVR"," |",[27,44,45],{"class":33}," xargs",[27,47,49],{"class":48},"sj4cs"," -n1",[27,51,52],{"class":37}," sslcheck\n",[10,54,55,56,59],{},"And ",[24,57,58],{},"sslcheck"," looks like this:",[17,61,63],{"className":19,"code":62,"language":21,"meta":22,"style":22},"\n# Do curl...\nRESPONSE=\"$(curl --HEAD --silent https:\u002F\u002F$DOMAIN)\";\n\nif [[ $RESPONSE = *\"200 OK\"* ]]; then\n  echo -e \"--- Found SSL! ---\";\nelse\n  echo -e \"--- Could not find SSL ---\";\nfi\n",[24,64,65,71,78,112,117,143,157,163,175],{"__ignoreMap":22},[27,66,67],{"class":29,"line":30},[27,68,70],{"emptyLinePlaceholder":69},true,"\n",[27,72,74],{"class":29,"line":73},2,[27,75,77],{"class":76},"sJ8bj","# Do curl...\n",[27,79,81,85,88,91,94,97,100,103,106,109],{"class":29,"line":80},3,[27,82,84],{"class":83},"sVt8B","RESPONSE",[27,86,87],{"class":41},"=",[27,89,90],{"class":37},"\"$(",[27,92,93],{"class":33},"curl",[27,95,96],{"class":48}," --HEAD",[27,98,99],{"class":48}," --silent",[27,101,102],{"class":37}," https:\u002F\u002F",[27,104,105],{"class":83},"$DOMAIN",[27,107,108],{"class":37},")\"",[27,110,111],{"class":83},";\n",[27,113,115],{"class":29,"line":114},4,[27,116,70],{"emptyLinePlaceholder":69},[27,118,120,123,126,128,131,134,137,140],{"class":29,"line":119},5,[27,121,122],{"class":41},"if",[27,124,125],{"class":83}," [[ $RESPONSE ",[27,127,87],{"class":41},[27,129,130],{"class":41}," *",[27,132,133],{"class":37},"\"200 OK\"",[27,135,136],{"class":41},"*",[27,138,139],{"class":83}," ]]; ",[27,141,142],{"class":41},"then\n",[27,144,146,149,152,155],{"class":29,"line":145},6,[27,147,148],{"class":48},"  echo",[27,150,151],{"class":48}," -e",[27,153,154],{"class":37}," \"--- Found SSL! ---\"",[27,156,111],{"class":83},[27,158,160],{"class":29,"line":159},7,[27,161,162],{"class":41},"else\n",[27,164,166,168,170,173],{"class":29,"line":165},8,[27,167,148],{"class":48},[27,169,151],{"class":48},[27,171,172],{"class":37}," \"--- Could not find SSL ---\"",[27,174,111],{"class":83},[27,176,178],{"class":29,"line":177},9,[27,179,180],{"class":41},"fi\n",[10,182,183],{},"This outputs a totally useless list of success and failure notifications with zero context.",[17,185,187],{"className":19,"code":186,"language":21,"meta":22,"style":22},"--- Could not find SSL ---\n--- Found SSL! ---\n--- Could not find SSL ---\n",[24,188,189,209,221],{"__ignoreMap":22},[27,190,191,194,197,200,203,206],{"class":29,"line":30},[27,192,193],{"class":33},"---",[27,195,196],{"class":37}," Could",[27,198,199],{"class":37}," not",[27,201,202],{"class":37}," find",[27,204,205],{"class":37}," SSL",[27,207,208],{"class":48}," ---\n",[27,210,211,213,216,219],{"class":29,"line":73},[27,212,193],{"class":33},[27,214,215],{"class":37}," Found",[27,217,218],{"class":37}," SSL!",[27,220,208],{"class":48},[27,222,223,225,227,229,231,233],{"class":29,"line":80},[27,224,193],{"class":33},[27,226,196],{"class":37},[27,228,199],{"class":37},[27,230,202],{"class":37},[27,232,205],{"class":37},[27,234,208],{"class":48},[10,236,237,238,240,241,243,244,251,252,255,256,258,259,262],{},"Obviously, we need to show what domain has SSL and which does not. I thought it would be cool to output the exact ",[24,239,93],{}," command executed, instead of just printing the ",[24,242,105],{}," variable. Here's the ",[245,246,250],"a",{"href":247,"rel":248},"https:\u002F\u002Fstackoverflow.com\u002Fa\u002F2853811",[249],"nofollow","Stack Overflow post"," which mentions the ",[24,253,254],{},"set -x"," option built in to Bash. Turn on with ",[24,257,254],{},", turn off with ",[24,260,261],{},"set +x",".",[17,264,266],{"className":19,"code":265,"language":21,"meta":22,"style":22},"# turn on command \"debugging\", or verbose mode \n# to output the curl command when we run it. \nset -x\n\n# Do curl...\nRESPONSE=\"$(curl --HEAD --silent https:\u002F\u002F$DOMAIN)\";\n# Turn off debug mode\nset +x\n\nif [[ $RESPONSE = *\"200 OK\"* ]]; then\n  echo -e \"--- Found SSL! ---\";\nelse\n  echo -e \"--- Could not find SSL ---\";\nfi\n",[24,267,268,273,278,286,290,294,316,321,328,332,351,362,367,378],{"__ignoreMap":22},[27,269,270],{"class":29,"line":30},[27,271,272],{"class":76},"# turn on command \"debugging\", or verbose mode \n",[27,274,275],{"class":29,"line":73},[27,276,277],{"class":76},"# to output the curl command when we run it. \n",[27,279,280,283],{"class":29,"line":80},[27,281,282],{"class":48},"set",[27,284,285],{"class":48}," -x\n",[27,287,288],{"class":29,"line":114},[27,289,70],{"emptyLinePlaceholder":69},[27,291,292],{"class":29,"line":119},[27,293,77],{"class":76},[27,295,296,298,300,302,304,306,308,310,312,314],{"class":29,"line":145},[27,297,84],{"class":83},[27,299,87],{"class":41},[27,301,90],{"class":37},[27,303,93],{"class":33},[27,305,96],{"class":48},[27,307,99],{"class":48},[27,309,102],{"class":37},[27,311,105],{"class":83},[27,313,108],{"class":37},[27,315,111],{"class":83},[27,317,318],{"class":29,"line":159},[27,319,320],{"class":76},"# Turn off debug mode\n",[27,322,323,325],{"class":29,"line":165},[27,324,282],{"class":48},[27,326,327],{"class":37}," +x\n",[27,329,330],{"class":29,"line":177},[27,331,70],{"emptyLinePlaceholder":69},[27,333,335,337,339,341,343,345,347,349],{"class":29,"line":334},10,[27,336,122],{"class":41},[27,338,125],{"class":83},[27,340,87],{"class":41},[27,342,130],{"class":41},[27,344,133],{"class":37},[27,346,136],{"class":41},[27,348,139],{"class":83},[27,350,142],{"class":41},[27,352,354,356,358,360],{"class":29,"line":353},11,[27,355,148],{"class":48},[27,357,151],{"class":48},[27,359,154],{"class":37},[27,361,111],{"class":83},[27,363,365],{"class":29,"line":364},12,[27,366,162],{"class":41},[27,368,370,372,374,376],{"class":29,"line":369},13,[27,371,148],{"class":48},[27,373,151],{"class":48},[27,375,172],{"class":37},[27,377,111],{"class":83},[27,379,381],{"class":29,"line":380},14,[27,382,180],{"class":41},[10,384,385],{},"Here's the much more useful output:",[17,387,389],{"className":19,"code":388,"language":21,"meta":22,"style":22},"++ curl --HEAD --silent https:\u002F\u002Fwww.site0.com\n+ RESPONSE='HTTP\u002F1.1 200 OK\nContent-Length: 0\nContent-Type: text\u002Fhtml; charset=UTF-8\n...\n'\n+ set +x\n--- Found SSL! ---\n++ curl --HEAD --silent https:\u002F\u002Fwww.site1.org\n+ RESPONSE=\n+ set +x\n--- Could not find SSL ---\n\n++ curl --HEAD --silent https:\u002F\u002Fwww.site2.com\n+ RESPONSE=\n+ set +x\n--- Could not find SSL ---\n",[24,390,391,406,414,419,424,429,434,443,453,466,473,481,495,499,512,519,528],{"__ignoreMap":22},[27,392,393,396,399,401,403],{"class":29,"line":30},[27,394,395],{"class":33},"++",[27,397,398],{"class":37}," curl",[27,400,96],{"class":48},[27,402,99],{"class":48},[27,404,405],{"class":37}," https:\u002F\u002Fwww.site0.com\n",[27,407,408,411],{"class":29,"line":73},[27,409,410],{"class":33},"+",[27,412,413],{"class":37}," RESPONSE='HTTP\u002F1.1 200 OK\n",[27,415,416],{"class":29,"line":80},[27,417,418],{"class":37},"Content-Length: 0\n",[27,420,421],{"class":29,"line":114},[27,422,423],{"class":37},"Content-Type: text\u002Fhtml; charset=UTF-8\n",[27,425,426],{"class":29,"line":119},[27,427,428],{"class":37},"...\n",[27,430,431],{"class":29,"line":145},[27,432,433],{"class":37},"'\n",[27,435,436,438,441],{"class":29,"line":159},[27,437,410],{"class":33},[27,439,440],{"class":37}," set",[27,442,327],{"class":37},[27,444,445,447,449,451],{"class":29,"line":165},[27,446,193],{"class":33},[27,448,215],{"class":37},[27,450,218],{"class":37},[27,452,208],{"class":48},[27,454,455,457,459,461,463],{"class":29,"line":177},[27,456,395],{"class":33},[27,458,398],{"class":37},[27,460,96],{"class":48},[27,462,99],{"class":48},[27,464,465],{"class":37}," https:\u002F\u002Fwww.site1.org\n",[27,467,468,470],{"class":29,"line":334},[27,469,410],{"class":33},[27,471,472],{"class":37}," RESPONSE=\n",[27,474,475,477,479],{"class":29,"line":353},[27,476,410],{"class":33},[27,478,440],{"class":37},[27,480,327],{"class":37},[27,482,483,485,487,489,491,493],{"class":29,"line":364},[27,484,193],{"class":33},[27,486,196],{"class":37},[27,488,199],{"class":37},[27,490,202],{"class":37},[27,492,205],{"class":37},[27,494,208],{"class":48},[27,496,497],{"class":29,"line":369},[27,498,70],{"emptyLinePlaceholder":69},[27,500,501,503,505,507,509],{"class":29,"line":380},[27,502,395],{"class":33},[27,504,398],{"class":37},[27,506,96],{"class":48},[27,508,99],{"class":48},[27,510,511],{"class":37}," https:\u002F\u002Fwww.site2.com\n",[27,513,515,517],{"class":29,"line":514},15,[27,516,410],{"class":33},[27,518,472],{"class":37},[27,520,522,524,526],{"class":29,"line":521},16,[27,523,410],{"class":33},[27,525,440],{"class":37},[27,527,327],{"class":37},[27,529,531,533,535,537,539,541],{"class":29,"line":530},17,[27,532,193],{"class":33},[27,534,196],{"class":37},[27,536,199],{"class":37},[27,538,202],{"class":37},[27,540,205],{"class":37},[27,542,208],{"class":48},[10,544,545],{},"Ta-da!",[547,548,549],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}",{"title":22,"searchDepth":73,"depth":73,"links":551},[],"2018-06-26T12:23:19-04:00",false,"md",{},"\u002Fposts\u002Ftoggle-debug-mode",{"title":5,"description":12},"posts\u002Ftoggle-debug-mode",[21,560],"til","3b4SNthQrrNSQPLMfiZea22WwdCPVfAGJjX2CVAa8Ms",1790471528106]