Advertisement
Guest User

majki

a guest
Jul 1st, 2010
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. USERNAME=""
  4. PASSWORD=""
  5. INTERVAL="2m"
  6. TIMEOUT=10000
  7.  
  8. COOKIEFILE="/tmp/hup.hu.cookies"
  9. EXITFILE="/tmp/hup.hu.exit"
  10. ICONFILE="/tmp/hup.hu.png"
  11.  
  12. NEEDAPPS="notify-send wget sed"
  13.  
  14. if [ "$1" == "-q" ]; then
  15.     touch "${EXITFILE}"
  16.     kill $(ps x | grep "sleep ${INTERVAL}" | grep -v grep | sed 's/\([0-9]\+\).*/\1/')  2>&1 >/dev/null
  17.     exit 0
  18. fi
  19.  
  20. for APP in $NEEDAPPS; do
  21.     if ! type -P $APP >/dev/null; then
  22.         echo "You need ${APP} to run this script."
  23.         exit 1
  24.     fi
  25. done
  26.  
  27. function CleanUp {
  28.     rm -f "${COOKIEFILE}"
  29.     rm -f "${ICONFILE}"
  30.     rm -f "${EXITFILE}"
  31. }
  32. CleanUp
  33.  
  34. # HUP Login
  35. USERID=$(wget -q -O- --keep-session-cookies \
  36.     --save-cookies "${COOKIEFILE}" \
  37.     --post-data="name=${USERNAME}&pass=${PASSWORD}&op=Bel%C3%A9p%C3%A9s&form_id=user_login_block" \
  38.     "http://hup.hu/modules.php?destination=node" | \
  39.     sed -n '/<li\ class="leaf"><a\ href="\/user\//s/.*\/user\/\([0-9]\+\)\">saj.*/\1/p')
  40.  
  41. if [ "_$USERID" == "_" ]; then
  42.     echo "Could not log in, or cannot find user ID."
  43.     exit 1
  44. fi
  45.  
  46. # Get the logo
  47. if [ ! -f "${ICONFILE}" ]; then
  48.     wget -q -O"${ICONFILE}" 'http://hup.hu/images/powered/hup_main.png'
  49. fi
  50.  
  51. # Get new message info
  52. while [ ! -f "${EXITFILE}" ]; do
  53.     wget -q -O- --keep-session-cookies \
  54.         --save-cookies "${COOKIEFILE}" \
  55.         --load-cookies "${COOKIEFILE}" \
  56.         "http://hup.hu/user/${USERID}/track" | tr ":" ";" | \
  57.         sed -n '/\(node\|cikkek\)\/[0-9]\+\(\/[A-Za-z0-9_]\+\)\?#new/s/.*\/\(node\|cikkek\)\/[0-9]\+\(\/[A-Za-z0-9_]\+\)\?\">\(.*\)<\/a>\s*<span\ class.*\/\(node\|cikkek\)\/\([0-9]\+\)\(\/[A-Za-z0-9_]\+\)\?#new\">\([0-9]\+\)\ .*<td>\(.*\)<\/td>.*/\3:\1:\5:\6:\7:\8/p' | \
  58.         while IFS=: read TITLE TYPE NUM URL NEW TIME; do
  59.             HUPURL="http://hup.hu/${TYPE}/${NUM}${URL}#new"
  60.             notify-send -i "${ICONFILE}" -u low -t ${TIMEOUT} "${TITLE}" "${NEW} új üzenet
  61. ${TIME}
  62. <a href=\"${HUPURL}\">${HUPURL}</a>" &
  63.         done
  64.     sleep "${INTERVAL}"
  65. done
  66.  
  67. CleanUp
  68. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement