Advertisement
HiImTye

tumblr.sh

Mar 16th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.22 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # a bash script to use curl to post, as a response to a question asked by the Neurolove facebook page:
  4. #  https://www.facebook.com/neurolove.me/posts/549604611804237
  5. # curl line adopted from the script by Andrea Olivato at:
  6. #  http://andreaolivato.tumblr.com/post/108364451/post-to-tumblr-via-bash-using-curl
  7. # -Tye
  8.  
  9. # check if we were interrupted last time
  10. if [ -f lastcount ]; then
  11.  # yes, start where we left off
  12.  . lastcount
  13. fi
  14.  
  15. while read title content; do
  16.  # check if we should skip this line because we were interrupted
  17.  if [ "$lastcount" -gt "$currentcount" ]; then
  18.   # yes
  19.   currentcount=$(( currentcount + 1 ))
  20.   continue
  21.  fi
  22.  
  23.  # no, send post as the user in var1 using the password in var2
  24.  curl -s -o /dev/null -d email="$1"&password="$2"&type=regular&title="$title"&body="$content"&generator=Bash
  25.  # delay our next post by the number of seconds defined in var3
  26.  sleep "$3"
  27.  # advance our count by 1
  28.  lastcount=$(( lastcount + 1 ))
  29.  currentcount="$lastcount"
  30.  # echo our count into our file, in case we're interrupted
  31.  echo "lastcount=$lastcount" > lastcount
  32. # substitute our input for the file specified in var4
  33. done < <(cat "$4")
  34.  
  35. # we're finished, remove our count file
  36. rm lastcount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement