tonybaldwin

friendicurl

Jun 29th, 2011
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # update friendika from bash with curl
  4. # I put this in my path as "friendicurl"
  5. # usage would be "friendicurl some text for update"
  6.  
  7. # here you enter your username and password
  8. # you could simply assign these variables
  9. # even in the curl command below, and skip this step.
  10. # If I weren't lazy, I would also make it so you could have a .friendicurl config file
  11. # to contain this data, I suppose...
  12.  
  13. read -p "username: " uname
  14. read -p "password:  " pwrd
  15.  
  16. # and the server on which your friendika is hosted (mine is http://friendika.openmindspace.org)
  17. read -p "server: " $url
  18.  
  19. # if you did not enter text for update, the script asks for it
  20.  
  21. if [[ $(echo $*) ]]; then
  22.     ud="$*"
  23. else
  24.     read -p "Enter your update text: " ud
  25. fi
  26.  
  27. # and this is the curl command that sends the update to the server
  28.  
  29. if [[ $(curl -u $uname:$pwrd -d status="$ud" $url/api/statuses/update.xml | grep error) ]]; then
  30.  
  31. # what does the server say?
  32.  
  33.     echo "Error"
  34. else
  35.     echo "Success!"
  36.     echo $ud
  37. fi
Advertisement
Add Comment
Please, Sign In to add comment