Advertisement
Guest User

lol

a guest
Jul 30th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. #!/bin/bash
  2. file="emails.txt"
  3. api_url="..."
  4. authorization="<user>:<api_key>"
  5.  
  6. mail_count=$(cat $file | wc -l)
  7. #convert to integer by adding 0:p
  8. mail_count=$(($mail_count+0))
  9. echo $mail_count
  10. json_arr="["
  11. i=1
  12. quote="\""
  13.  
  14. while read line
  15. do
  16.     json_arr+=$quote
  17.     json_arr+=$line
  18.     json_arr+=$quote
  19.    
  20.     if [ $i -ne $mail_count ]
  21.     then
  22.         json_arr+=","
  23.     fi
  24.  
  25.     i=$((i + 1))
  26. done <$file
  27.  
  28. json_arr+="]"
  29.  
  30. json_data="{\"mails\":$json_arr}"
  31.  
  32. 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