Posts Tagged bash

新浪微博使用curl

  1. SINAUSER=username
  2. SINAPASS=password
  3. SINACOOKIE=/path/store/sina/cookie
  4. curl -d "service=miniblog&entry=miniblog&username=${SINAUSER}&password=${SINAPASS}&url=http://t.sina.com.cn/ajaxlogin.php"  "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.0)" -e "http://t.sina.com.cn/" -c ${SINACOOKIE} -s >> /dev/null
  5.  curl -d "content=${STATUS}&pic=&from=myprofile" "http://t.sina.com.cn/mblog/publish.php" -e "http://t.sina.com.cn/jinuljt" -b ${SINACOOKIE}

,

No Comments

同时更新renren与twitter

同时更新 renren与twitter状态的bash脚本。

对于renren网,使用curl模拟登录与提交。
之与twiiter则使用curl直接调用其api提交。

  1. #!/bin/bash
  2. CURL=/usr/bin/curl
  3. COOKIE=/tmp/renren.cookie
  4. STATUS=$1
  5. RRUSER=renren username
  6. RRPASS=renren password
  7. TWUSER=twitter username
  8. TWPASS=twitter password
  9. ${CURL} -d "email=${RRUSER}&password=${RRPASS}" "http://passport.renren.com/PLogin.do"   -c ${COOKIE} -L -s  >> /dev/null
  10. RESPONSE=`${CURL} -d "c=${STATUS}&raw=${STATUS}&isAtHome=1" "http://status.renren.com/doing/update.do?" -e "http://status.renren.com/ajaxproxy.htm"  -b ${COOKIE} -L -s`
  11. #echo ${RESPONSE}
  12. echo "Update renren.com"
  13. if echo ${RESPONSE}|grep -q "updateStatusId"
  14. then
  15. echo "successful"
  16. else
  17. echo "fail"
  18. fi
  19.  
  20. RESPONSE=`${CURL} -u "${TWUSER}:${TWPASS}" -d status="${STATUS}" https://twitter.com/statuses/update.xml -s`
  21. #echo ${RESPONSE}
  22. echo "Update twitter.com"
  23. if echo ${RESPONSE}|grep -q "status"
  24. then
  25. echo "successful"
  26. else
  27. echo "fail"
  28. fi

, ,

2 Comments

inotifywait + rsync 同步源代码

  1. #!/bin/sh
  2. SRC_DIR=$1
  3. DST_DIR=$2
  4. #etc:rsync_moniter /home/user/cpp_src user@pc_name:/home/user/
  5. echo "if there file modify,create,delete happens on  \"$1\" ,it will auto  rsync with \"$2\""
  6. inotifywait -mrq –exclude ".*(swp|swx|~)" -e modify,create,delete $SRC_DIR|
  7. while read line
  8. do
  9. rsync -a $SRC_DIR $DST_DIR
  10. done

一般在本机上写代码,需要在rhel5上面编译,跑程序。

懒得复制来复制去的(- -b,代码相当ugly,debug比较多)。

inotifywait监控文件增删改,然后调用rsync同步文件。

, ,

No Comments