Dec 6, 2009

A good way to replace notepad.exe without touch system32 folder

In short, create a key (notepad.exe) under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options (in 64bit system it is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Image File Execution Options). Create an string item named Debugger, put in the path of your favorite editor.

But wait, it's not end yet. Your editor need a special treatement, e.g. you need special version of notepad2.exe from http://code.kliu.org/misc/notepad2/ to get it work.

Fortunately there are other ways to make this solution more generic. check it at http://www.vistax64.com/tutorials/244527-programs-replace-system-program-without-modifying-system-files-permissions.html

Jun 29, 2009

Compile seagull-1.8.0.1 on RHLS 5.3 X64

Download seagull source package (seagull-1.8.0.1-svn.tar.gz) from http://gull.sourceforge.net/download/index.html.

Unpack the package, follow the manual (http://gull.sourceforge.net/doc/core.html#Compiling+Seagull+from+source+code). you will end up with an error:
-----------------------------------------
cc1plus: warnings being treated as errors
protocol-text/C_MessageText.cpp: In member function ‘C_ProtocolFrame::_msg_error_code C_MessageText::EncodeWithContentLength(int)’:
protocol-text/C_MessageText.cpp:62: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘size_t’
protocol-text/C_MessageText.cpp:62: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘size_t’
make[1]: *** [/tmp/seagull.svn/work-1.8.0.1/C_MessageText.o] Error 1
-----------------------------------------
This is caused by -Werror flag in the compilation option. Modify build.conf, remove all -Werror flag, you can continue with the compilation process. However, in the linking stage, you get the following error:
-----------------------------------------
[Linking /tmp/seagull.svn/build-1.8.0.1/libtrans_ip.so]
/usr/bin/ld: /tmp/seagull.svn/work-1.8.0.1/C_RegExp.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/seagull.svn/work-1.8.0.1/C_RegExp.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [/tmp/seagull.svn/build-1.8.0.1/libtrans_ip.so] Error 1
make[1]: Leaving directory `/tmp/seagull.svn'
make: *** [all_libtrans_ip.so] Error 2
-----------------------------------------
By adding -fPIC to BUILD_EXE_CC_FLAGS_LINUX and BUILD_LIB_CC_FLAGS_LINUX options defined in build.conf and run ./build.ksh -target clean and then rebuild, you finally get the seagull build successfully.

May 6, 2009

Shell history

Modern shell (BASH) provides history functionality enable you to play with previous typed command easily. Native users us up-down arrows to locate the command line. While hacker's way is always through magic shortcuts.

This article is a good guide on how to play with shell history.

Here is a cheat sheet for shell history hacking

May 5, 2009

cygwin, wget and http_proxy

usually wget will automatically use the proxy setting defined in $http_proxy environment variable. Unfortunately, set http_proxy environment with command line tools (e.g. setx and setenv) does not work. Specifically, after the environment set up with the command line tools, if you type

c:\>set http_proxy
c:\>http_proxy=<your proxy setting>

But if you type

c:\>env | grep http_proxy

you get nothing.

I am pretty surprised here but no clue found on google. Fortunately, there is one way around. put the following line in the .wgetrc file in your home directory:
http_proxy=yourproxysetting
ftp_proxy=yourproxysetting

PS: the reason I need everything be put into command line script is I use a script to switch my work environment in corporate (where proxy effective) and home (no proxy at all).

Apr 15, 2009

unix tool: paste

1. attach line number to a file
seq `wc -l
2. join multiple lines
seq 9 | paste -d" " -s -

3. join two files by columns
paste -d", " <(cut -d", " -f1 $FILE1) <(cut -d"," -f3,4 $FILE2)

Apr 1, 2009

bash script: how to handle command line arguments

There is one example shell script demonstrate how to use getopt (GNU version) to parse command line argument handling. getopt GNU version is able to parse both short and long options. The bash built-in getopts cannot process long option.

This post (in Chinese) is a very good reference for getopt

Mar 26, 2009

NFS problem: RPC Error: Program not registered

I have prepared the /etc/exports, executed exportfs -ua; exportfs -a at the server side (a RHLS). The fstab file is setup at the client side. There is no problem in the content of these files (they are verified at other server/client pairs). But when I invoke mount -a in the client side I get the following error:

RPC Error: Program not registered

This error message is rather misleading, someone is the net argue that it is caused by the network mask setting in the /etc/exports, while there are a dozen of other causes found by google. The real cause of my case is that nfs is not started in RHLS. Everything went fine after I have invoked "/etc/init.d/nfs restart"

Mar 22, 2009

Cruisecontrol JavaMail error

I have configured htmlemail publisher for the cruisecontrol. Unfortunately, I have encountered the following error while sending email:
501 5.0.0 HELO requires domain address.

After some digging on google, the solution is found to be add
127.0.0.1 <$(hostname)> in the etc/hosts file.

Mar 12, 2009

Find the full path of your bash script

Usually people use the following way to get the fullpath of bash script (for the sake of various reasons, like locate the base dir etc):
export mypath=$dirname{"$0"}


However you can't get absolute path with this method, it get the relative path of $0

Someone use this code to probe the path:
export mypath=$dirname{$PWD}


This is unfortunately does NOT reach your goal: to get the full path of the script location. It turns out the full path of your current dir when you invoke the script.

A tested solution is provided by someone's posts to this thread:

#!/bin/bash
#==========================
# bash - find path to script
#==========================
abspath=$(cd ${0%/*} && echo $PWD/${0##*/})

# to get the path only - not the script name - add
path_only=`dirname "$abspath"`

#display the paths to prove it works
echo $abspath
echo $path_only


Another interesting article about this topic can be found at google code

Mar 10, 2009

Install virtualbox on ubuntu 8.10

virtualbox is a virtualization solution for x86.

I am trying to install virtualbox on ubuntu 8.10 amd64 with "sudo aptitude install virtualbox-ose". It ends up with the following error message:


Error! Your kernel source for kernel 2.6.2-7-generic cannot be found at /lib/modules/2.6.27-7-generic/build or /lib/modules/2.6.27-7-generic/source. Installing initial module

Error! Could not locate vboxdrv.ko for module vboxdrv in the DKMS tree.
You must run a dkms build for kernel 2.6.27-7-generic (x86_64) first.


This error is solved by running "sudo aptitude install linux-headers-$(uname -r)" as suggested by some Einstein at here.

Mar 8, 2009

CruiseControl modificationset not work on SVN

I am trying to apply CruiseControl on PoC CP building. One strange problem I have encountered is cruisecontrol cannot detect the modification in SVN, i.e. someone commit new changes into SVN, but cruisecontrol was not able to detect the modification, in the log file you can find "No modifications found, build not necessary", even though the svnbootstrapper has just updated the changes from repository to your local copy.

This is found due to the time on the SVN server behind the time on the build server. After correct the time lag, everything went fine