Guest User

bash

a guest
May 1st, 2016
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. COUNT=0
  3. SUCCESS=0
  4. FAIL=0
  5. touch success.txt
  6. trap ctrl_c SIGINT SIGTERM
  7. function print_results() {
  8. echo
  9. echo "Succeeded: $SUCCESS, Failed: $FAIL, Total: $COUNT"
  10. }
  11. function ctrl_c() {
  12. print_results
  13. exit 0
  14. }
  15. while read id ; do
  16. ((COUNT++))
  17. if grep -Fxq "$id" success.txt; then
  18. ((SUCCESS++))
  19. continue
  20. fi
  21. echo -n "$COUNT: $id"
  22. output=`REPLACE_THIS_WITH_CURL --silent`
  23. if [[ ${PIPESTATUS[0]} -gt 0 ]]; then
  24. ((FAIL++))
  25. echo ", curl failed!"
  26. elif echo "$output" | grep -q 'has already been purchased.'; then
  27. ((SUCCESS++))
  28. echo ", succeeded - already owned!"
  29. echo $id >> success.txt
  30. elif echo "$output" | grep -q 'has been added to your assets.'; then
  31. ((SUCCESS++))
  32. echo ", succeeded!"
  33. echo $id >> success.txt
  34. elif echo "$output" | grep -q 'moving around data. The site will be right back.'; then
  35. ((FAIL++))
  36. echo ", failed - site will be right back"
  37. else
  38. ((FAIL++))
  39. echo ", failed - unknown error"
  40. fi
  41. sleep 5
  42. done
  43. print_results
Advertisement
Add Comment
Please, Sign In to add comment