Guest

k_haciendo

By: a guest on Mar 9th, 2010  |  syntax: Bash  |  size: 2.00 KB  |  hits: 347  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #!/usr/bin/env bash
  2.  
  3. # ======= Initial checks ============
  4. if [[ ! -e /usr/bin/html2text ]]; then
  5.     echo "You need install html2text before using $0"
  6.     echo "    In Ubuntu/Debian use: \$apt-get install html2text"
  7.     exit 0
  8. fi
  9.  
  10. if [[ "${#@}" -eq "1" ]]; then
  11.     case "$1" in
  12.         u)
  13.         curl -s http://mononeurona.org/waydings/addwayd | html2text
  14.         exit 0
  15.         ;;
  16.         up)
  17.         curl -s http://mononeurona.org/waydings/addwayd | html2text
  18.         exit 0
  19.         ;;
  20.         update)
  21.         curl -s http://mononeurona.org/waydings/addwayd | html2text
  22.         exit 0
  23.         ;;
  24.         -u)
  25.         curl -s http://mononeurona.org/waydings/addwayd | html2text
  26.         exit 0
  27.         ;;
  28.         -up)
  29.         curl -s http://mononeurona.org/waydings/addwayd | html2text
  30.         exit 0
  31.         ;;
  32.         -update)
  33.         curl -s http://mononeurona.org/waydings/addwayd | html2text
  34.         exit 0
  35.         ;;
  36.         --update)
  37.         curl -s http://mononeurona.org/waydings/addwayd | html2text
  38.         exit 0
  39.         ;;
  40.     esac
  41. fi
  42. # ============ Settings =============
  43. #Avoid writing user/password every time
  44. #MNron=your_email_just_as_you_login_at_mononeurona_dot_org
  45. #MNpwd=your_password
  46. MNtask="$@"
  47. # ===================================
  48.  
  49. if [[ -z "${MNron}" ]]; then
  50.     echo -n "User: "
  51.     read -e MNron
  52. fi
  53.  
  54. if [[ -z "${MNpwd}" ]]; then
  55.     echo -n "Password: "
  56.     read -e MNpwd
  57. fi
  58.  
  59. if [[ -z "${MNtask}" ]]; then
  60.     echo -n "k estas haciendo?: "
  61.     read -e MNtask
  62. fi
  63.  
  64. curl -s -c /tmp/MNc -d "_method=POST&data[User][email]=$MNron&data[User][pwd]=$MNpwd" http://mononeurona.org/users/login > /tmp/MN.log
  65.  
  66. SIZE_log=`ls -l /tmp/MN.log | awk '{ print $5 }'`
  67.  
  68. if [[ $SIZE_log -gt 0 ]]; then
  69.     echo "$0: user or password incorrect"
  70.     exit 0
  71. fi
  72.  
  73. curl -s -b /tmp/MNc  -d "_method=POST&data[Wayding][task]=$MNtask" http://mononeurona.org/waydings/addwayd | html2text
  74.  
  75. #====Clean up variables=====
  76. unset MNron
  77. unset MNpwd
  78. unset MNtask
  79. rm /tmp/MN.log