Advertisement
Guest User

kakka

a guest
Jul 31st, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #a test script to test how the api call to get badgeback emails for the given email list handles shitload of parameters
  4. #(a kinda bruteforce test because the api should split dabase queries into multiple parts when there are enough #parameters)
  5.  
  6. function help {
  7.     echo "USAGE: ./test1.sh or ./test1.sh help for showing help message. example: ./test1.sh > results.json to redirect output to another file"
  8.     exit 0 
  9. }
  10.  
  11. if [ $# -eq 1 ]
  12. then
  13.     if [ $1 == "help" ]
  14.     then
  15.         help
  16.     fi
  17. fi
  18.  
  19. api_url="<enkerro>"
  20. authorization="<enkerro>"
  21. #parameters for the api call, a list of emails
  22. #file containing thousands of fake and non-fake email addresses
  23. file="emails.txt"
  24. #how many parameters
  25. mail_count=$(cat $file | wc -l)
  26. #convert to integer by adding 0:p
  27. mail_count=$(($mail_count+0))
  28. #echo $mail_count
  29.  
  30. #form the json array for the emails
  31. json_arr="["
  32. i=1
  33. quote="\""
  34.  
  35. #kinda like "join" call in another languages, forms a comma separated list in the form of ["mail1","mail2","mail3",...."mailn"]
  36. while read line
  37. do
  38.     json_arr+=$quote
  39.     json_arr+=$line
  40.     json_arr+=$quote
  41.    
  42.     if [ $i -ne $mail_count ]
  43.     then
  44.         json_arr+=","
  45.     fi
  46.  
  47.     i=$((i + 1))
  48. done <$file
  49.  
  50. json_arr+="]"
  51.  
  52. json_data="{\"mails\":$json_arr}"
  53. #echo $json_data
  54. curl -X POST -H 'Content-Type: application/json' -d $json_data  $api_url --user $authorization
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement