Skip to content
Feb 27 11

Nikon D7000 SDK object hierarchy diagram

by admin

Wrote a C program to control my Nikon D7000 camera to capture a picture in less than a second. Here is the SDK module object hierarchy diagram I drew.
Nikon D7000 SDK

Feb 17 11

Tunnelling Firefox traffic over ssh

by admin

Facebook and Yourtube are blocked in China, I had to tunnel all web browser traffic over ssh.

1. Install ssh server on your home computer
2. Open the sshd port number in your router configuration
3. On your local machine, run
ssh -fnD localhost:$NONE_USED_PORT ip_address_of_your_home_computer
for example:
ssh -fnD localhost:9999 public_ip_address_of_your_home_network
4. Configure Firefox to use the tunnel
Edit->Preferences-> Advanced -> Network -> Settings
Select Manual proxy configuration, enter localhost in the SOCKS Host field and the port you used for your tunnel, in my example above: 9999
5. Configure Firefox to use the tunnel also for DNS
Enter about:config in the address field, and search for network.proxy.socks_remote_dns and set it to true
6. Stop the tunnelling
ps -ef | grep ssh
Kill the SSH process with localhost:9999

Feb 15 11

Portlet vs Pagelet – Oracle

by admin

A portlet is a reusable Web component that can draw content from many different sources. Portlets provide a means of presenting data from multiple sources in a meaningful and related way.

A pagelet is a reusable user interface component similar to a portlet, but while portlets were designed specifically for portals, pagelets are designed to run on any web page.

Source: Oracle WebCenter documentation

Feb 12 11

.bashrc file in my Oracle WebCenter Server

by admin
# User specific aliases and functions
ORACLE_SID=orcl
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
PATH=$ORACLE_HOME/bin::$PATH
JDEV_USER_DIR=/u01/JDevApps
PATH=$ORACLE_HOME/bin:/u01/app/oracle/product/JDeveloper/jdeveloper/jdev/bin:$PATH
export ORACLE_SID ORACLE_HOME ORACLE_BASE JDEV_USER_DIR PATH

alias sys='sqlplus "/ as sysdba"'
Feb 12 11

Authentication error when try to start up a WebLogic server

by admin

Fix:

1. add boot.properties file in /u01/app/oracle/product/Middleware/user_projects/domains/webcenter/servers/SERVER_NAME/security.
My example
/u01/app/oracle/product/Middleware/user_projects/domains/webcenter/servers/WC_Spaces/security

username=weblogic
password=mypassword

Do not copy from other server because they are encrypted like this.
#Sat Feb 12 12:51:05 PST 2011
password={AES}HMwLqIUUkL/UNHsRsFgEd4JtKDNbbKDg+OVUFvb9+t8\=
username={AES}o6OyJ4g/rSlQDTtN6YDP/jHrOKEumCJ1IdtSMwiJzOQ\=

2. Remove or move the ldap directory.
/u01/app/oracle/product/Middleware/user_projects/domains/webcenter/servers/WC_Spaces/data]

Feb 12 11

“IS_SEEDED”: invalid identifier

by admin

I got this error when I tried to start up WC_Spaces server (webcenter spaces).

java.sql.SQLSyntaxErrorException: ORA-00904: “IS_SEEDED”: invalid identifier

Fix:

Run RCU to recreate the PORTAL_WEBCENTER schema, and modify the domain JDBC connection properties of WC_Spaces in Enterprise Manager.

Feb 12 11

Scripts to start Oracle WebLogic / WebCenter servers

by admin

#!/bin/bash

DATE=`date +%A" "%d-%b-%Y-%X`

DATESTAMP=`date +%d-%b-%Y-%T`

clear

echo " ** Oracle WebCenter Administration Menu **"

echo " "

echo "             "$DATE"                       "

echo " "

echo "0.  STOP  ALL - [Stops: DB, Listener, AdminServer, UCM_Server1"

echo "                 WC_Portlet, WC_CustomPortal]"

echo " "

echo "1.  START Content Server - [Starts: Database, Listener, AdminServer"

echo "                            UCM_Server1]"

echo "2.  START AviTrust - [Starts: Database, Listener, AdminServer"

echo "                      UCM_Server1, WC_CustomPortal]"

echo " "

echo "3.  START Oracle Database and Listener "

echo "4.  START Oracle Weblogic Server [AdminServer]"

echo "5.  START Oracle ECM [UCM_server1] "

echo "6.  START Oracle WC_CustomPortal [WC_CustomPortal] "

echo "7.  START Oracle WC_Portlet [WC_Portlet] "

echo " "

echo "8. STOP  Oracle ECM [UCM_server1] "

echo "9. STOP  Oracle WC_CustomPortal [WC_CustomPortal] "

echo "10. STOP  Oracle WC_Portlet [WC_Portlet] "

echo "11. STOP  Oracle Weblogic Server [AdminServer] "

echo "12. STOP  Oracle Database and Listener "

echo "13. START Oracle WebSpaces "

echo "14. START Oracle Collaboration "

echo "15. START Oracle Utilities "

echo " "

echo "X.  EXIT from this Menu "

echo " ***********************************************************"

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

export PATH=$ORACLE_HOME/bin:$PATH

export ORACLE_SID=orcl

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export DOMAIN_HOME=/u01/app/oracle/product/Middleware/user_projects/domains/webcenter

ADMIN_PORT=7001

PORTLET_PORT=8889

PORTAL_PORT=8892

UCM_PORT=16200

SPACES_PORT=8888

COLLABORATION_PORT=8890

UTILITIES_PORT=8891

#echo "\n X.  Exit from Menu"

echo "Enter the Administration Option (X to exit menu): "

read ADMINTASK

#

if [[ -z $ADMINTASK ]]; then

   echo "Please enter a numeric value from the Menu!"

else

case $ADMINTASK in

#---------------------------------------------------------------------------------------------

"1")

clear

#

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`

if [ $lsnr_num -gt 0 ]

then echo "Database Listener Already RUNNING."

else echo "Starting Infrastructure Database Listener..."

$ORACLE_HOME/bin/lsnrctl start

fi

db_num=`ps -ef|grep pmon |grep -v grep |awk 'END{print NR}'`

if [ $db_num -gt 0 ]

then echo "Database Already RUNNING."

else echo "Starting Oracle Database ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

startup

EOF

#

sleep 10

echo "Database Services Successfully Started. "

#

fi

admin_num=`ps -ef|grep "$ADMIN_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $admin_num -gt 0 ]

then echo "WebLogic Admin Server Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WebLogic Admin Server...."

nohup ./startWebLogic.sh > weblogic.out &

admin_run=`grep -i RUNNING weblogic.out|grep -v grep |awk 'END{print NR}'`

while [ $admin_run -eq 0 ]

do

sleep 5;

admin_run=`grep -i RUNNING weblogic.out|grep -v grep |awk 'END{print NR}'`

done

fi

ucm_num=`netstat -nl|grep "$UCM_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $ucm_num -gt 0 ]

then echo "UCM_server1 Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting UCM_server1...."

nohup ./startManagedWebLogic.sh UCM_server1 > ucm.out &

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`

while [ $ucm_run -eq 0 ]

do

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

#---------------------------------------------------------------------------------------------

"2")

clear

#

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`

if [ $lsnr_num -gt 0 ]

then echo "Database Listener Already RUNNING."

else echo "Starting Infrastructure Database Listener..."

$ORACLE_HOME/bin/lsnrctl start

fi

db_num=`ps -ef|grep pmon |grep -v grep |awk 'END{print NR}'`

if [ $db_num -gt 0 ]

then echo "Database Already RUNNING."

else echo "Starting Oracle Database ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

startup

EOF

#

sleep 10

echo "Database Services Successfully Started. "

#

fi

admin_num=`ps -ef|grep "$ADMIN_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $admin_num -gt 0 ]

then echo "WebLogic Admin Server Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WebLogic Admin Server...."

nohup ./startWebLogic.sh > weblogic.out &

admin_run=`grep -i RUNNING weblogic.out|grep -v grep |awk 'END{print NR}'`

while [ $admin_run -eq 0 ]

do

sleep 5;

admin_run=`grep -i RUNNING weblogic.out|grep -v grep |awk 'END{print NR}'`

done

fi 

ucm_num=`netstat -nl|grep "$UCM_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $ucm_num -gt 0 ]

then echo "UCM_server1 Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting UCM_server1...."

nohup ./startManagedWebLogic.sh UCM_server1 > ucm.out &

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`

while [ $ucm_run -eq 0 ]

do

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`

done

fi

custom_num=`netstat -nl|grep "$PORTAL_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $custom_num -gt 0 ]

then echo "WC_CustomPortal Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WC_CustomPortal...."

nohup ./startManagedWebLogic.sh WC_CustomPortal > customportal.out &

sleep 5;

custom_run=`grep -i "Server started in RUNNING mode" customportal.out|grep -v grep |awk 'END{print NR}'`

while [ $custom_run -eq 0 ]

do

sleep 5;

custom_run=`grep -i "Server started in RUNNING mode" customportal.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

#---------------------------------------------------------------------------------------------

"3")

clear

#

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`

if [ $lsnr_num -gt 0 ]

then echo "Database Listener Already RUNNING."

else echo "Starting Infrastructure Database Listener..."

$ORACLE_HOME/bin/lsnrctl start

fi

db_num=`ps -ef|grep pmon |grep -v grep |awk 'END{print NR}'`

if [ $db_num -gt 0 ]

then echo "Database Already RUNNING."

else echo "Starting Oracle Database ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

startup

EOF

#

sleep 10

echo "Database Services Successfully Started. "

#

fi

;;

#---------------------------------------------------------------------------------------------

#---------------------------------------------------------------------------------------------

"4")

echo "Starting WLS_Admin ...."

admin_num=`netstat -nl|grep "$ADMIN_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $admin_num -gt 0 ]

then echo "WebLogic Admin Server Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WebLogic Admin Server...."

nohup ./startWebLogic.sh > weblogic.out &

sleep 5;

admin_run=`grep -i "Server started in RUNNING mode" weblogic.out|grep -v grep |awk 'END{print NR}'`

while [ $admin_run -eq 0 ]

do

sleep 5;

admin_run=`grep -i "Server started in RUNNING mode" weblogic.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

#---------------------------------------------------------------------------------------------

"5")

ucm_num=`netstat -nl|grep "$UCM_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $ucm_num -gt 0 ]

then echo "UCM_server1 Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting UCM_server1...."

nohup ./startManagedWebLogic.sh UCM_server1 > ucm.out &

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`

while [ $ucm_run -eq 0 ]

do

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

#---------------------------------------------------------------------------------------------

#---------------------------------------------------------------------------------------------

"6")

custom_num=`netstat -nl|grep "$PORTAL_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $custom_num -gt 0 ]

then echo "WC_CustomPortal Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WC_CustomPortal...."

nohup ./startManagedWebLogic.sh WC_CustomPortal > customportal.out &

sleep 5;

custom_run=`grep -i "Server started in RUNNING mode" customportal.out|grep -v grep |awk 'END{print NR}'`

while [ $custom_run -eq 0 ]

do

sleep 5;

custom_run=`grep -i "Server started in RUNNING mode" customportal.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

#---------------------------------------------------------------------------------------------

#---------------------------------------------------------------------------------------------

"7")

portlet_num=`netstat -nl|grep "$PORTLET_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $portlet_num -gt 0 ]

then echo "WC_Portlet Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WC_Portlet...."

nohup ./startManagedWebLogic.sh WC_Portlet > portlet.out &

sleep 5;

portlet_run=`grep -i "Server started in RUNNING mode" portlet.out|grep -v grep |awk 'END{print NR}'`

while [ $portlet_run -eq 0 ]

do

sleep 5;

portlet_run=`grep -i "Server started in RUNNING mode" portlet.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

#--------------------------------------------------------------------------------------------

#--------------------------------------------------------------------------------------------

#---------------------------------------------------------------------------------------------

"8")

echo "Stopping  Oracle UCM [UCM_server1] ... "

cd $DOMAIN_HOME/bin

./stopManagedWebLogic.sh UCM_server1

;;

#---------------------------------------------------------------------------------------------

#---------------------------------------------------------------------------------------------

"9")

echo "Stopping  WC_CustomPortal ... "

cd $DOMAIN_HOME/bin

./stopManagedWebLogic.sh WC_CustomPortal

;;

#---------------------------------------------------------------------------------------------

#---------------------------------------------------------------------------------------------

"10")

echo "Stopping  WC_Portlet ... "

cd $DOMAIN_HOME/bin

./stopManagedWebLogic.sh WC_Portlet

;;

#---------------------------------------------------------------------------------------------

"11")

echo "Stopping Admin Server [WLS_Admin] ..."

cd $DOMAIN_HOME/bin

./stopWebLogic.sh

;;

#--------------------------------------------------------------------------------------------

"12")

echo "Stopping Oracle Database and Listener ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

shutdown immediate

EOF

#

$ORACLE_HOME/bin/lsnrctl stop

sleep 10;

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`

if [ $lsnr_num -gt 0 ]

then kill -9 `ps -deafw | grep "$ORACLE_HOME" | grep -v grep |  awk '{print $2}' | paste -s -d" " -`

fi

;;

"13")

spaces_num=`netstat -nl|grep "$SPACES_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $spaces_num -gt 0 ]

then echo "WC_Spaces Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WC_Spaces...."

nohup ./startManagedWebLogic.sh WC_Spaces > spaces.out &

sleep 5;

spaces_run=`grep -i "Server started in RUNNING mode" spaces.out|grep -v grep |awk 'END{print NR}'`

while [ $spaces_run -eq 0 ]

do

sleep 5;

spaces_run=`grep -i "Server started in RUNNING mode" spaces.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

"14")

coll_num=`netstat -nl|grep "$COLLABORATION_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $coll_num -gt 0 ]

then echo "WC_Collboration Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WC_Collaboration...."

nohup ./startManagedWebLogic.sh WC_Collaboration > coll.out &

sleep 5;

coll_run=`grep -i "Server started in RUNNING mode" coll.out|grep -v grep |awk 'END{print NR}'`

while [ $coll_run -eq 0 ]

do

sleep 5;

coll_run=`grep -i "Server started in RUNNING mode" coll.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

"15")

util_num=`netstat -nl|grep "$UTILITIES_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $util_num -gt 0 ]

then echo "WC_Utilities Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin

echo "Starting WC_Utilities...."

nohup ./startManagedWebLogic.sh WC_Utilities > util.out &

sleep 5;

util_run=`grep -i "Server started in RUNNING mode" util.out|grep -v grep |awk 'END{print NR}'`

while [ $util_run -eq 0 ]

do

sleep 5;

util_run=`grep -i "Server started in RUNNING mode" util.out|grep -v grep |awk 'END{print NR}'`

done

fi

;;

"0")

clear

cd $DOMAIN_HOME/bin

echo "Stopping Database,WLS_Admin,WC_CustomPortal,WC_Portlet,UCM_Server1 ..."

./stopManagedWebLogic.sh WC_CustomPortal

./stopManagedWebLogic.sh WC_Portlet

./stopManagedWebLogic.sh UCM_server1

./stopWebLogic.sh

echo "Stopping Oracle Database and Listener ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

shutdown immediate

EOF

#

$ORACLE_HOME/bin/lsnrctl stop

sleep 10;

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`

if [ $lsnr_num -gt 0 ]

then kill -9 `ps -deafw | grep "$ORACLE_HOME" | grep -v grep |  awk '{print $2}' | paste -s -d" " -`

fi

;;

"X")

clear

exit

;;

esac

fi
Jan 28 11

Read new Gmail messages from command line

by admin
#!/usr/bin/python

import imaplib, sys

conn = imaplib.IMAP4_SSL(host='imap.gmail.com')
# or conn =imaplib.IMAP4(host='mail.oracleabc.com') for no SSL

try:
    (retcode, capabilities) = conn.login('tom.luo', 'mypassword')
except:
    print sys.exc_info()[1]
    sys.exit(1)
conn.select(readonly=1) # Select inbox or default namespace
(retcode, messages) = conn.search(None, '(UNSEEN)')
if retcode == 'OK':
    for message in messages[0].split(' '):
        print 'Message ID :', message
        # read SUBJECT
        (ret, mesginfo) = conn.fetch(message, '(BODY[HEADER.FIELDS (SUBJECT FROM)])')
        # read the message BODY
        # (ret,mesginfo) = conn.fetch(message, '(UID BODY[TEXT])')

        if ret == 'OK':
            print mesginfo
conn.close()
Jan 26 11

Rich Client Application integrated with Google Map

by admin

I am building a rich client application using Oracle JDeveloper ADF JSF.
I need to get longitude and latitude of some sample data.

Search for a location on Google map, when the location is in the center of the map, copy and paste this code into the location bar of your browser and press enter:

javascript:void(prompt(”,gApplication.getMap().getCenter()));

Calgary: (51.045, -114.057222)

Jan 23 11

Change term custom prompt (PS1) to hostname

by admin

PS1=”\h.”

or

PS1=”`hostname`.”

Jan 22 11

Get package info

by admin

Ubuntu
apt-cache show package_name
apt-cache show python

CentOS
rpm -qi package_name
rpm -qi python

Jan 22 11

vim: windows and tabs

by admin

Edit files in multiple windows
ctr + w + v to edit in vertical split windows
ctr + w + s to edit in horizontal split windows
ctr + w + w to switch between windows

Open multiple files in tabs
vi -p file1.txt file2.txt
– switch between tabs
:tabn
:tabp

Jan 22 11

Talk to a remote user on Ubuntu

by admin

# Install talk and talkd
sudo apt-get install talk
sudo apt-get install talkd

talk oracle@192.168.0.111
talk oracle@192.168.0.222

# It runs on port number 518
$lsof -i :518
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
talk 2423 oracle 3u IPv4 17231 0t0 UDP localhost.localdomain:59261->localhost.localdomain:ntalk
talk 2423 oracle 4u IPv4 17232 0t0 UDP ubuntuAir:59031->sony:ntalk
talk 2697 oracle 3u IPv4 18015 0t0 UDP localhost.localdomain:38688->localhost.localdomain:ntalk
talk 2697 oracle 4u IPv4 18016 0t0 UDP ubuntuAir:56328->sony:ntalk

Jan 20 11

Install Ubuntu from USB stick

by admin

$sudo apt-cache search usb-creator
usb-creator-common – create a startup disk using a CD or disc image (common files)
usb-creator-gtk – create a startup disk using a CD or disc image (for GNOME)
usb-creator-kde – create a startup disk using a CD or disc image (for KDE)

# Choose the package for your desktop
# Install hte usb-creator for GNOME
sudo apt-get install usb-creator-gtk

Run usb-creator-gtk
Then the choose the ISO file of your Ubuntu image.

Click ‘Make Startup Disk ‘

Then boot the computer from USB

Jan 20 11

Oracle Fusion Middleware Architecture Graphs

by admin

Source: Oracle SOA Documentations

SOA

Grid Infrastructure

WebLogic

Jan 20 11

startNodeManager.sh

by admin

In Oracle WebLogic, you must start Node Manager before you can start an SOA managed server.
cat /oracle/fmwhome/wlserver_10.3/server/bin/startNodeManager.sh

#!/bin/sh
# *************************************************************************
# This script can be used to start the WebLogic NodeManager
#
# To start the NodeManager on <host> and <port>, set the LISTEN_ADDRESS
# variable to <host> and LISTEN_PORT variable to <port> before calling this
# script.
#
# This script sets the following variables before starting the NodeManager:
#
# BEA_HOME       - The BEA root installation directory.
# WL_HOME        - The root directory of your WebLogic installation.
# NODEMGR_HOME   - The root directory for this NodeManagerInstance.
# JAVA_HOME      - Location of the version of Java used to start WebLogic
#                  Server. This variable must point to the root directory of a
#                  JDK installation and will be set for you by the installer.
#                  See the Oracle Fusion Middleware Supported System Configurati
ons page
#                  (http://www.oracle.com/technology/software/products/ias/files
/fusion_certification.html)
#                  for an up-to-date list of supported JVMs.
# PATH           - Adds the JDK and WebLogic directories to the system path.
# CLASSPATH      - Adds the JDK and WebLogic jars to the classpath.
# JAVA_OPTIONS   - Java command-line options for running the server. (These
#                  will be tagged on to the end of the JAVA_VM and MEM_ARGS)
# JAVA_VM        - The java arg specifying the VM to run.  (i.e. -server,
#                  -hotspot, etc.)
# MEM_ARGS       - The variable to override the standard memory arguments
#                  passed to java
#
# Alternately, this script will take the first two positional parameters and
# set them to LISTEN_ADDRESS and LISTEN_PORT. For instance, you could call this
# script: "sh startNodeManager.sh holly 7777" to start the NodeManager
# on host holly and port 7777, or just "sh startNodeManager.sh holly"
# to start the node manager on host holly.
# *************************************************************************

# Set user-defined variables.
unset JAVA_VM MEM_ARGS

WL_HOME="/oracle/fmwhome/wlserver_10.3"
. "${WL_HOME}/common/bin/commEnv.sh"

NODEMGR_HOME="${WL_HOME}/common/nodemanager"

# If NODEMGR_HOME does not exist, create it
if [ ! -d "${NODEMGR_HOME}" ]; then
  echo ""
  echo "NODEMGR_HOME ${NODEMGR_HOME} does not exist, creating it.."
  mkdir -p "${NODEMGR_HOME}"
fi

# Set first two positional parameters to LISTEN_ADDRESS and LISTEN_PORT
if [ "${1}" != "" ]; then
  LISTEN_ADDRESS="${1}"
fi

if [ "${2}" != "" ]; then
  LISTEN_PORT="${2}"
fi

# Check for JDK
if [ ! -d "${JAVA_HOME}/bin" ]; then
  echo "The JDK wasn't found in directory ${JAVA_HOME}."
  echo "Please edit the startNodeManager.sh script so that the JAVA_HOME"
  echo "variable points to the location of your JDK."
  exit 1

else

if [ "${MEM_ARGS}" = "" ]
then
MEM_ARGS="-Xms32m -Xmx200m"
fi

set -x
CLASSPATH="${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${CLASSPATH}${CLASSPATHSEP}${BEA_
HOME}"
export CLASSPATH
export PATH

cd "${NODEMGR_HOME}"
set -x
if [ "$LISTEN_PORT" != "" ]
 then
   if [ "$LISTEN_ADDRESS" != "" ]
    then
     "${JAVA_HOME}/bin/java" ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Djava.secur
ity.policy="${WL_HOME}/server/lib/weblogic.policy" -Dweblogic.nodemanager.javaHo
me="${JAVA_HOME}" -DListenAddress="${LISTEN_ADDRESS}" -DListenPort="${LISTEN_POR
T}" weblogic.NodeManager -v
    else
     "${JAVA_HOME}/bin/java" ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Djava.secur
ity.policy="${WL_HOME}/server/lib/weblogic.policy" -Dweblogic.nodemanager.javaHo
me="${JAVA_HOME}" -DListenPort="${LISTEN_PORT}" weblogic.NodeManager -v
   fi
 else
   if [ "$LISTEN_ADDRESS" != "" ]
    then
     "${JAVA_HOME}/bin/java" ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Djava.secur
ity.policy="${WL_HOME}/server/lib/weblogic.policy" -Dweblogic.nodemanager.javaHo
me="${JAVA_HOME}" -DListenAddress="${LISTEN_ADDRESS}" weblogic.NodeManager -v
    else
     "${JAVA_HOME}/bin/java" ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Djava.secur
ity.policy="${WL_HOME}/server/lib/weblogic.policy" -Dweblogic.nodemanager.javaHo
me="${JAVA_HOME}" weblogic.NodeManager -v
   fi
fi
set +x
Jan 19 11

xxd

by admin

xxd – make a hexdump or do the reverse

xxd fibo.py > fibo.hex
xxd -r fibo.hex
0000000: 2321 2f75 7372 2f62 696e 2f70 7974 686f  #!/usr/bin/pytho
0000010: 6e0a 6465 6620 6669 6228 6e29 3a20 2020  n.def fib(n):
0000020: 2023 2077 7269 7465 2046 6962 6f6e 6163   # write Fibonac
0000030: 6369 2073 6572 6965 7320 7570 2074 6f20  ci series up to
0000040: 6e0a 2020 2020 612c 2062 203d 2030 2c20  n.    a, b = 0,
0000050: 310a 2020 2020 7768 696c 6520 6220 3c20  1.    while b <
0000060: 6e3a 0a20 2020 2020 2020 2070 7269 6e74  n:.        print
0000070: 2062 2c0a 2020 2020 2020 2020 612c 2062   b,.        a, b
0000080: 203d 2062 2c20 612b 620a 0a64 6566 2066   = b, a+b..def f
0000090: 6962 3228 6e29 3a20 2320 7265 7475 726e  ib2(n): # return
00000a0: 2046 6962 6f6e 6163 6369 2073 6572 6965   Fibonacci serie
00000b0: 7320 7570 2074 6f20 6e0a 2020 2020 7265  s up to n.    re
00000c0: 7375 6c74 203d 205b 5d0a 2020 2020 612c  sult = [].    a,
00000d0: 2062 203d 2030 2c20 310a 2020 2020 7768   b = 0, 1.    wh
00000e0: 696c 6520 6220 3c20 6e3a 0a20 2020 2020  ile b < n:.
00000f0: 2020 2072 6573 756c 742e 6170 7065 6e64     result.append
0000100: 2862 290a 2020 2020 2020 2020 612c 2062  (b).        a, b
0000110: 203d 2062 2c20 612b 620a 2020 2020 7265   = b, a+b.    re
0000120: 7475 726e 2072 6573 756c 740a            turn result.
Jan 18 11

Deploy Oracle WebLogic Fusion Order Demo Application

by admin

Error #1

I got two build errors when I was trying to Deploy the WebLogic Fusion Order Demo Application.

[copy] Copying 2 files to /scratch/aime1/jdeveloper/mywork/soa_demo/CompositeServices/B2BX12OrderGateway/dist
[jar] Building jar: /scratch/aime1/jdeveloper/mywork/soa_demo/CompositeServices/B2BX12OrderGateway/deploy/sca_B2BX12OrderGateway_rev1.0.jar

BUILD FAILED
/scratch/aime1/jdeveloper/mywork/soa_demo/CompositeServices/bin/build.xml:185: The following error occurred while executing this line:
/scratch/aime1/jdeveloper/mywork/soa_demo/CompositeServices/B2BX12OrderGateway/bin/build_sca_composite.xml:52: The following error occurred while executing this line:
/scratch/aime1/jdevhome/jdeveloper/bin/ant-sca-package.xml:109: Problem creating jar: /scratch/aime1/jdeveloper/mywork/soa_demo/CompositeServices/B2BX12OrderGateway/dist/SCA-INF/classes/.data (No such file or directory)

1. setupWorkspaceForJDeveloperUse
2. seedFodJmsResources
3. seedDemoUsers
4. compile-build-all

Fix:

I did not run the targets in the correct order.
I had to delete the entire fod directory and rebuilt the targets in the following sequence.

Do not run the next target in the sequence until the previous one completes successfully. In the Apache Ant – Log, ensure you see the following message before proceeding to the next script:

1. setupWorkspaceForJDeveloperUse This script sets up the application workspace in Oracle JDeveloper.
2. seedFodJmsResources This script populates the JMS resources for the Fulfillment mediator.
3. seedDemoUsers This script adds jstein as the user to approve orders for over $2,000. When you run the demo, you place an order for $2,000 and log in to the Oracle BPM Worklist as jstein and approve the order.
If you do not run this script, the OrderProcessor BPEL process generates a recoverable error and assigns the task to the weblogic administrator.

4. compile-build-all This script compiles and builds all the SOA composites.
5. compile-deploy-all This script compiles, builds, and deploys all the SOA composites to the Managed Server for Oracle SOA Suite.

BUILD SUCCESSFUL
Total time: nn minutes nn seconds

Below is my build.properties file.


####################################################################
#       Global build property set for SOA fusion order demo        #
# > author: clemens utschig (oracle corp) 2009                     #
####################################################################

# path for libraries and script imports
oracle.home=/oracle/jdevhome/jdeveloper
################ INTERNAL SEED PROPERTIES - BEGIN ##################
#                                                                  #
#                   !!!!! DO NOT MODIFY !!!!!                      #
#                                                                  #
####################################################################

# internal version number
fod.version=2.3_ps2

# common libs home
oracle.common.home=${oracle.home}/../oracle_common

# Sub directory for deployment artifacts
deploy.sub.dir=deploy
# sub directory for deployment / build scripts
bin.sub.dir=bin

# jee application homes
creditauthorization.home=../CreditCardAuthorization
orderapproval.home=../OrderApprovalHumanTask
external.partnersupplier.home=../ExternalLegacyPartnerSupplierEjb
# composite homes
orderbookingsdo.composite.home=../OrderSDOComposite
partnersupplier.composite.home=../PartnerSupplierComposite
orderbooking.composite.home=../OrderBookingComposite
b2b.composite.home=../B2BX12OrderGateway

# adf service implementation context url
storefrontservice.contextUri.adf=StoreFrontServiceHooks/StoreFrontService
# sca composite based context url
storefrontservice.contextUri.soa=soa-infra/services/${soa.partition.name}/OrderSDOComposite!1.0/StoreFrontService

# ejb uri for the ExternalPartnerSupplierEJB
partnersupplier.ejb.uri=WebLogicFusionOrderDemo-ExternalLegacyPartnerSupplierEjb-SessionEJB#com.otn.sample.fod.soa.externalps.IExternalPartnerSupplierService
# ejb uri for the ExternalPartnerSupplierEJB JSca implementation via Spring C&I
partnersupplier.jsca.ejb.uri=WebLogicFusionOrderDemo-ExternalLegacyPartnerSupplierJScaEjb

## global connection settings for deployer, rmi and others

# admin server t3:// url - for deployment
wls.url=t3://${admin.server.host}:${admin.server.port}
# mgd server t3:// url - for ejb
wls.mgd.server.url=t3://${managed.server.host}:${managed.server.rmi.port}
# the jndi ctx factory
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory

################## INTERNAL SEED PROPERTIES - END ####################

# partition where the composites should be deployed to
soa.partition.name=tluoPartition

# set to false if you want to use adf backed services.
soa.only.deployment=true

# deploy the b2b x12 order processing composite
enable.b2b.composite=true

# use a normal ejb3 for the external partner supplier (comment or set to false),
# or use the new Weblogic SCA for Java EJB binding (uncomment and set to true)
use.jsca.ejb.impl=true

# file adapter directory - amend to your OS (use \\ for windows and / for unix)
orderbooking.file.adapter.dir=/tmp

# file adapter control directory - amend to your OS (use \\ for windows and / for unix)
orderbooking.file.adapter.control.dir=/tmp/control

# jndi name of the jms topic for orderbooking composite
orderbooking.jms.topic.jndi=jms/DemoSupplierTopicUdd

###### Deployment server connection information 

# the admin server connection information - to seed the topics
admin.server.host=localhost
admin.server.port=7001

# the domain where soa infra is installed
server.domain.name=domain1

# connection information for the managed server, used for soa-deployment, http
managed.server.host=localhost
managed.server.port=8001

# rmi port for testing, ejb invocation and others
managed.server.rmi.port=8001

# credential information for the servers
server.user=weblogic
server.password=welcome1

# wls target server (for shiphome set to server_soa, for ADRS use AdminServer)
server.targets=soa_server1

# soa-server side oracle home directory - needed for deployment plans
# and the weblogic sca library deployment (out of the ExternalPartnerSupplier project
soa.server.oracle.home=/oracle/fmwhome/Oracle_SOA1

####### for business event testing - this is to enqueue the business event 

# soa db main schema username
soa.db.username=dev_mds
# soa db password
soa.db.password=welcome1
# soa db connect string => host:port:sid
soa.db.connectstring=localhost:1521:xe

##### MetaDataServices repository settings (used for SOA shared artifacts) #####

# use "jdev" for local jdeveloper install, "db" for database
# In case of "db" amend the below (jdbc) settings for the mds db

foreign.mds.type=db

# Note: BEFORE you deploy make sure you amend these settings to your REMOTE
# db - that is backing soa-infra, set the above mds.type to "db" and run
# the "importCommonServiceArtifactsIntoMds" target. This will import the common
# shared artifacts of $OH/bin/soa-seed/ into the remote (RT) mds.
# On a shiphome install this user is normally named sh_mds

mds.db.userid=dev_mds
mds.db.password=welcome1
# database connection string: driver@host:port:sid
mds.db.jdbc-url=jdbc:oracle:thin:@localhost:1521:xe

Error #2.
Target state: deploy failed on SOA Server

Fix: Correct the soa.server.oracle.home.

soa.server.oracle.home=/oracle/fmwhome/Oracle_SOA1

Error 3
I got “BAD_CERTIFICATE” error when I tried to start a managed soa_server.

Fix
Disabled the SSL.

Set JAVA_OPTIONS in /oracle/fmwhome/user_projects/domains/domain1/bin/setSOADomainEnv.sh

JAVA_OPTIONS=”${JAVA_OPTIONS} ${JAVA_PROPERTIES} -Dweblogic.security.SSL.ignoreHostnameVerify=true”

And Set SecureListener=false in /oracle/fmwhome/wlserver_10.3/common/nodemanager.

Start the Node manager by running
/oracle/fmwhome/wlserver_10.3/server/bin/startNodeManager.sh

Then you can start the managed server “soa_server1 ”

Managed SOA

Deploy FOD

Jan 17 11

msmtp on Ubuntu

by admin
sudo apt-get install msmtp
vi ~/.msmtprc

defaults
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log

account gmail
host smtp.gmail.com
from tom.luo@gmail.com
auth on
user tom.luo
password xxxxxx

# Set a default account
account default : gmail

chmod 600 .msmtp

#Send attachment.txt to myself
msmtp tom.luo@gmail.com < attachment.txt

msmtp --serverinfo
SMTP server at smtp.gmail.com (px-in-f109.1e100.net [74.125.155.109]), port 25:
    mx.google.com ESMTP u5sm4158803ics.6
TLS certificate information:
    Owner:
        Common Name: smtp.gmail.com
        Organization: Google Inc
        Locality: Mountain View
        State or Province: California
        Country: US
    Issuer:
        Common Name: Google Internet Authority
        Organization: Google Inc
        Country: US
    Validity:
        Activation time: Thu 22 Apr 2010 02:02:45 PM MDT
        Expiration time: Fri 22 Apr 2011 02:12:45 PM MDT
    Fingerprints:
        SHA1: 1A:6F:48:8F:BE:5B:FD:92:D8:12:30:F9:22:CE:84:49:B3:43:BD:2C
        MD5:  60:39:DE:FB:0A:D9:9E:43:26:E7:75:AC:60:48:A1:B0
Capabilities:
    SIZE 35651584:
        Maximum message size is 35651584 bytes = 34.00 MiB
    STARTTLS:
        Support for TLS encryption via the STARTTLS command
    AUTH:
        Supported authentication methods:
        PLAIN LOGIN
Jan 11 11

A few shell commands

by admin

To print and count the names of the users who use bash

awk -F: '/bash$/{nlines++; print $1;} END {print "\n", nlines} ' /etc/passwd
# find regular file named 'a.txt' under /home/oracle
find /home/oracle -name a.txt -type f 

#find directory named 'temp' under /home/oracle
find /home/oracle -name temp -type d 

Extract MAC address from ifconfig

[root@node1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:F6:94:D7
          inet addr:172.16.3.192  Bcast:172.16.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef6:94d7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29286 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1504 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3698231 (3.5 MiB)  TX bytes:153568 (149.9 KiB)

[root@node1 ~]# ifconfig eth0 | awk '/eth0/ {print $5}'
08:00:27:F6:94:D7
[root@node1 ~]# ifconfig eth0 | awk '/HW/ {print $5}'
08:00:27:F6:94:D7
[root@node1 ~]# ifconfig eth0 | awk '/HWaddr/ {print $5}'
08:00:27:F6:94:D7
[root@node1 ~]# ifconfig eth0 | awk '/Ethernet/ {print $5}'
08:00:27:F6:94:D7

MAC address is the 5th element of the mathed line splitted by a space.

Similar code in Python

s="eth0      Link encap:Ethernet  HWaddr 08:00:27:F6:94:D7"
.s.split()
['eth0', 'Link', 'encap:Ethernet', 'HWaddr', '08:00:27:F6:94:D7']
.s.split()[4]
'08:00:27:F6:94:D7'

Ignore errors
Ignore permission denied error in find results. Since errors are printed to stderr, they can be suppressed by redirecting the output to /dev/null.

find / -name "fibo.py" -type f -print 2>/dev/null