Posts Tagged bash

新浪微博使用curl

SINAUSER=username
SINAPASS=password
SINACOOKIE=/path/store/sina/cookie
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
 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提交。

#!/bin/bash
CURL=/usr/bin/curl
COOKIE=/tmp/renren.cookie
STATUS=$1
RRUSER=renren username
RRPASS=renren password
TWUSER=twitter username
TWPASS=twitter password
${CURL} -d "email=${RRUSER}&password=${RRPASS}" "http://passport.renren.com/PLogin.do"   -c ${COOKIE} -L -s  >> /dev/null
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`
#echo ${RESPONSE}
echo "Update renren.com"
if echo ${RESPONSE}|grep -q "updateStatusId"
then
echo "successful"
else
echo "fail"
fi

RESPONSE=`${CURL} -u "${TWUSER}:${TWPASS}" -d status="${STATUS}" https://twitter.com/statuses/update.xml -s`
#echo ${RESPONSE}
echo "Update twitter.com"
if echo ${RESPONSE}|grep -q "status"
then
echo "successful"
else
echo "fail"
fi

, ,

2 Comments

inotifywait + rsync 同步源代码

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

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

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

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

, ,

No Comments

SetTextSize SetPageWidth