yichao firstname, zeaster nickname, zhang lastname

blogsync FAQ

 



blogsync FAQ


from http://code.google.com/p/blogsync-java/wiki/BlogsyncFAQ

what is blogsync?


it is used to import wordpress posts into blogger.

how to use it?



  • set jdk bin path in run.bat/run.sh

  • execute run.bat/run.sh


what is new in blogsync 0.3?


The comments can be imported from wordpress rss xml file to blogger site now. However it can not preserve the published time of the wordpress comments. so the published time of your imported comments is just the time when you import.

what is new in blogsync 0.2?


add feature to import posts from exported wordpress rss xml file to blogger site.

which jdk version do I need to run blogsync?


You should use jdk1.5 or later.

how to add jdk bin path in path environment?



  • windows

    1. says your java.exe is in directory c:\jdk1.5.0\bin

    2. set the following line in run.bat

    3.     set path=c:jdk1.5.0bin;%path%



  • Mac or unix

    1. says your java is in directory /path/to/your/java

    2. set the following line in run.sh

    3.     export PATH=/path/to/your/java:$PATH




how do I know which version of jdk I am using?


open a terminal, type "java -version". you should get something like this:
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode)

how to run run.bat/run.sh in command line?



  • windows

  • open a command window, type:
        cd e:pathtoyourrun.bat
    run
    .bat


  • Mac or unix

  • open a terminal, type:
        cd /path/to/your/run.sh
    sh run
    .sh



when run run.sh, it is opened by my editor, what should I do?


please run run.sh in command line.

after clicking on run.bat/run.sh, there was nothing happend, what should I do?


run run.bat/run.sh in command line so that find what's going wrong in the terminal?

It prompts "java: command not found", what's going wrong?


java is not in your path, please add jdk bin path in your path environment.

why do I get Exception in thread "main" java.lang.NoClassDefFoundError: org/easter/blogsync/BlogSync?


if you are on Mac or unix, please make sure you have read permission on blogsync/build/blogsync.jar file if not, open a terminal and type:
chmod 744 /path/to/your/blogsync/build/blogsync.jar

why do I get Failed to create input stream: Server returned HTTP response code: 403 for URL: http://mydomain.com/wordpress/xmlrpc.php?



  • if you installed a plugin called Enforce www. Preference, it would affect the path to your xmlrpc.php file, so deactivated it first.

  • if you enabled mod_security on apache, it would block access to xmlrpc.php, so add this to your .htaccess file:

  •     <Files xmlrpc.php>
    SecFilterInheritance Off
    </Files>


python script to email me the dynamic ip from tp-link router

At home, my boxes are connected to internet by Beijing ADSL.
when connected, Beijing ADSL gives me a dynamic ip and it changes about every 24 hours.
Before I get the dynamic ip by a service provided by oray.net.
However recently the service is broken.
So I have to write a python script to check the dynamic ip from my tp-link router every 3 minutes and if it changed, emails the new dynamic ip to my gmail.

I also write a bash script to run the above python script at boot on my gentoo linux.

The python script:


#!/usr/bin/python

import urllib
import urllib2
import libgmail
import cookielib
import sys
import re
import base64
import socket
import time
from urlparse import urlparse

nowip=''
logfile=open('/var/log/ipsender.log','w')

def log(s):
now=time.strftime('%Y-%m-%d %X')
logfile.write('%s %sn'%(now,s))
logfile.flush()

def gmailsender(to_addr,subject,msg):
username='xxx@gmail.com'
password='xxx'
ga=libgmail.GmailAccount(username,password)
ga.login()
gmsg=libgmail.GmailComposedMessage(to_addr,subject,msg)
ga.sendMessage(gmsg)

def check():
global nowip
timeout=10
socket.setdefaulttimeout(timeout)
username = 'admin'
password = 'xxx'
try:
theurl='http://192.168.1.1/userRpm/StatusRpm.htm'
req = urllib2.Request(theurl)
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
authheader = "Basic %s" % base64string
req.add_header("Authorization", authheader)
handle = urllib2.urlopen(req)
str=handle.read()
ss='var wanPara = new Array'
start=str.index(ss)+ss.__len__()
end=str.index(';',start)
s2=str[start:end]
log(s2)
t=eval(s2)
log(t[2])
handle.close()
if nowip!=t[2]:
nowip=t[2]
gmailsender('mygmail@gmail.com','ddnsip===%s'%nowip,s2)
log('send %s successfully.'%nowip)
else:
log('ddnsip remains %s.'%nowip)
except:
log('Unexpected error:', sys.exc_info()[0])

def main():
while True:
check()
time.sleep(3*60)

main()

The bash script put in /etc/init.d/:

#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
start() {
ebegin "Starting ipsender"
nohup python /home/zeaster/amp/ipsender.py >> /var/log/ipsender-nohup.log&
eend $?
}
stop() {
ebegin "Stopping ipsender unsuccessfully"
eend $?
}