0

I have a file of domain names (~9000 urls). I am trying to determine the time taken to execute a successful curl request for all the urls.

#!/bin/bash

#read lines from file. 
while read -r line || [[ -n "$line" ]]; do

#Start execution time. 
start=`date +%s.%N`

curl -k -L $line

if (("$?" != "7")) || (("$?" != "6")) ||(("$?" != "35")) ; then  

#If curl request is not one of these [error codes][1] then end execution time
    end=`date +%s.%N`
fi
runtime=$( echo "$end - $start" | bc -l ) >> throughput.txt

#Can do an average on the file later. 


done < urls.txt

For some reason the loop stops after reading the first url. Can someone please help me correctly run the script.

  • Put set -x at the top of your script to get a better idea of what is going wrong. – DepressedDaniel Dec 17 '16 at 6:06
  • It stop after the the curl command curl -k -L $line – user192795 Dec 17 '16 at 6:18
  • Maybe post the output to a pastebin and include link here – DepressedDaniel Dec 17 '16 at 6:23
  • You can also use time command to measure duration of you curl command, like 'time curl -k -L $line'. You can also specify output format for time command. – StefanR Dec 17 '16 at 8:15
  • pastebin.com/LZmNevYa – user192795 Dec 17 '16 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy