From 8817a7b1c855a1cf4e12aad2b5235d200313c992 Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Sat, 26 Apr 2014 22:43:44 +0200 Subject: [PATCH] testtop1m.sh: correct counting of background jobs `jobs` command returns multiple lines for a jobs with `if` so counting number of background jobs was off --- top1m/testtop1m.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/top1m/testtop1m.sh b/top1m/testtop1m.sh index 71b1b0f..72b09bb 100755 --- a/top1m/testtop1m.sh +++ b/top1m/testtop1m.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash parallel=50 -max_bg=400 +max_bg=50 [ ! -e "results" ] && mkdir results function wait_for_jobs() { @@ -13,6 +13,20 @@ function wait_for_jobs() { done } +function scan_host() { + tcping -u 10000000 $1 443; + if [ $? -gt 0 ];then + tcping -u 10000000 www.$1 443; + if [ $? -gt 0 ]; then + return; + else + ../cipherscan -json www.$1:443 > results/www.$t + return; + fi; + fi; + ../cipherscan -json $t:443 > results/$t +} + i=0 count=$(wc -l top-1m.csv | awk '{print $1}') while [ $i -lt $count ] @@ -20,16 +34,7 @@ do echo processings sites $i to $((i + parallel)) for t in $(tail -$(($count - $i)) top-1m.csv | head -$parallel |cut -d ',' -f 2) do - (tcping -u 10000000 $t 443; - if [ $? -gt 0 ];then - tcping -u 10000000 www.$t 443; - if [ $? -gt 0 ]; then - continue; - else - ../cipherscan -json www.$t:443 > results/www.$t - continue; - fi; - fi;../cipherscan -json $t:443 > results/$t )& + (scan_host $t)& done i=$(( i + parallel)) wait_for_jobs $max_bg