Wednesday, April 9, 2014

Add Sudoer

Platform: RHEL

Config File: /etc/sudoers

Add username as the following format:

user MACHINE=COMMANDS
like
username ALL=(ALL)     ALL

Sunday, March 9, 2014

Generate a Date Range in MySQL

Set @i:=0;

SELECT DATE(DATE_ADD( '2014-03-01' - INTERVAL 1 DAY, INTERVAL @i:=@i+1 DAY ) ) AS datesSeries
FROM `CS3_Statistics`.`HC_Report`, (SELECT @i:=0) r
where @i < DATEDIFF( '2014-03-07' + INTERVAL 1 DAY, '2014-03-01' )
;


Thursday, October 10, 2013

Java 7 IP 6 to 4

Java 7 is using IP6 for its connectivity by default, to disable it and use IP4 the following setting can be set in windows or unix environment to override it

_JAVA_OPTIONS -Djava.net.preferIPv4Stack=true


Saturday, September 21, 2013

TCL Expect Script Directory

These are expect parameter to work with command line options:

puts $argc     # number of argument passed to script
puts $argv    # array list of arguement, script name not included
puts $argv0  # the name of script include path of calling e.g. ./test.sh

set path [file dirname $argv0]    # obtain script directory
cd $path      # Change directory to script directory



# Find script path through links as well
set originalPath [pwd]
set scriptPath   $::argv0
set workingPath  [file dirname $::argv0]
while {![catch {file readlink $scriptPath} result]} {
    cd $workingPath
    set scriptPath  [file join [pwd] $result]
    set workingPath [file dirname $scriptPath]
}
cd [file dirname $scriptPath]
set scriptPath [pwd]
cd $originalPath

Wednesday, August 28, 2013

Read and Clear big wtmpx

Read
/usr/lib/acct/fwtmp < wtmpx


Clear
cd /var/adm
gzip -c wtmpx > wtmpx-2013.gz
> wtmpx

Friday, June 28, 2013

Adding New Xml Encoding Alias to Xerces

Recently I developed an xmlrpc application that failed on testing from an existing client (the stupid one). That client set its request encoding in xml header as "UTF8" (the standard IANA is "UTF-8"). It result in rejecting the request immediately in xmlroc server (I deployed in Jboss EAP 6.1) by following exception.

Invalid encoding name "UTF8"

So after searching I found the EncodingMap class of xerces that allow add new alias for encoding names. So first add xercesImpl dependency in maven file, an then statically add the desired encoding name as follow:

EncodingMap.putIANA2JavaMapping( "UTF8", "UTF8" );

EncodingMap.putJava2IANAMapping( "UTF8", "UTF8" );


Saturday, June 8, 2013

Create Solaris 10 IPMP

Requirement:
2 connected interface
3 IP addresses (1 for active, 2 for interface tests)

It is probe based IPMP (testing destination IP)

Update /etc/hosts
10.132.174.144    hostaddress

10.132.174.146    host-testaddr0
10.132.174.146    host-testaddr1

ifconfig intf0 host-testaddr0 deprecated -failover netmask + broadcast + group host_g0 up
ifconfig intf0 addif hostaddress netmask + broadcast + up

ifconfig intf1 host-testaddr1 deprecated -failover netmask + broadcast + group host_g0 up

Make it permanent by /etc/hostname.intfx