Search Results

Saturday, February 20, 2016

Unix Tips

Unix Tips

# These commands gets executed when the use logs in the shell
# File path: $home/.bashrc

# Setting Path
export PATH=/u01/app/oracle/products/jdk1.8.0_66/bin:$PATH

# Setting variables
export DHOME

export LOGS

# Settings aliases
alias domain='cd /u01/app/oracle/products/jdk1.8.0_66/bin'

Other useful commands

# List out running processes
ps -ef | grep java

# Push a foreground process into background
^z ; # suspends the foreground process
bg ; # pushes suspended process into background process

# zip and unzip folders
zip -r soasit_domain

# Find a text in files
find . "*.xml" | xargs grep -il "searchText"

# Matching any line which start with echo egrep '^(( )+|( )?)echo' filename

# Monitoring Log files
tail -100f filename

# Set putty title
echo -e "\033]0; `hostname` \007\c"

# Color ls
alias l='ls --color=auto -lrt'

# Change the date stamp on the file
touch -r referenceFile filename

# Cpu usage

#Query Memory info
Total Memory: grep MemTotal /proc/meminfo
Swap Space: grep SwapTotal /proc/meminfo
Shared Memory: df -k /dev/shm/
Free Memory: free

#Find system details
Processor info: grep "model name" /proc/cpuinfo
System Architecture: uname -m
Disk Space: df -h
Linux version: cat /proc/version
Kernel Version: uname -r
Hostname: hostname

Users and Groups

# Add user and groups
/usr/sbin/useradd -g oinstall -G dba oracle
/usr/sbin/groupadd oinstall

#To change the Password: 

#Display user details: 
id oracle

# Assign user group and groups

/usr/sbin/usermod -g oinstall -G dba oracle

# Change Path for all users


tar cvzf foo.tgz *.cc *.h This creates (c) a compressed (z) tar file named foo.tgz (f) and shows the files (v). tar cvzf foo.tgz cps100 >> will tar the directory cps100 tar tzf foo.tgz >>To see a tar file's table of contents tar xvzf foo.tgz >> To extract the contents of a tar file This untars/extracts (x) into the directory, prints the files (v). tar xvzf foo.tgz You can extract only one (or several) files

Vi Scripts

To repalace the last occuring character "/" with Tab :%s,/\([^/]*$\),\t\1, Eg: /home/prasanna/temp/hill.txt results in /home/prasanna/temp hill.txt

Finding files in Linux based on time

find . -name "hello" -printf "%a %c %t %f \n" find . -follow \( -mtime 2 -o -mtime +2 \) -print %a - access time (reading, coping) %c - Changed time of file parameters or properties %t - modify time of file content %f - filename without dirs -atime n - accessed n days ago -mtime n - modified n days ago -ctime n - changed n days ago

# Find and delete files older than a day

find . -mtime +1 -exec rm {} \;


#Telnet to test host port 
telnet hostname port

#Alternative to telnet
nc -zv hostname port

#Could be used to test connectivity as well
openssl s_client -connect

#Local port forwarding
ssh -L 2521:destinationhost:1521 remotehost

#Remote port forwarding
ssh -R 2521:destinationhost:1521 remotehost

#Forwarding GUI programs
ssh -X remotehost

To learn more about port forwarding check

FTPs (FTP over ssl)

Commands to transfer files to FTPs server (also called as FTP over ssl). 

#upload file
curl -v --user username:password --ftp-ssl  -k ftp://Ftp_Hostname:21/home/folder1/ -T TestFile

#List files
curl --user username:password --ftp-ssl -l  -k ftp://Ftp_Hostname:21/home/folder1/*

#Download file
curl --user username:password --ftp-ssl  -k ftp://Ftp_Hostname:21/home/folder1/TestFile -o TestFile

#Delete file
curl -v --user username:password --ftp-ssl  -k ftp://Ftp_Hostname:21/home/folder1/ -Q "DELE /home/folder1/TestFile"

Tuesday, February 16, 2016

Useful xslt code

How to convert XML list into comma seperated list

 <xsl:for-each select="/ns0:UserId">
            <xsl:value-of select="."/>
            <xsl:if test="position() != last()">




How to strip of empty elements from xml

This xslt code work with any XML types, so it could be saved in a common location and used everywhere.

<xsl:stylesheet version="2.0" xmlns:xsl="" xmlns:xs="" xmlns:fn="" exclude-result-prefixes="fn xs">
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:template match="node()|@*">
                <xsl:if test="normalize-space(string(.)) != ''">
                                <xsl:apply-templates select="node()|@*"/>

How to find distinct values and group in XSLT

This xslt will groups the xml elements by distinct UserID

 <xsl:key name="UserId" match="/ns0:queryResponse/ns0:QueryResults/ns0:records/ns0:UserId/text()"
  <xsl:template match="/">
      <xsl:for-each select="/ns0:queryResponse/ns0:QueryResults/ns0:records/ns0:UserId/text()[generate-id() = generate-id(key('UserId',.)[1])]">
            <xsl:value-of select="."/>
          <xsl:call-template name="getResponsibility">
            <xsl:with-param name="UserId" select="."/>
            <xsl:with-param name="records" select="/ns0:queryResponse/ns0:QueryResults/ns0:records"/>
  <xsl:template name="getResponsibility">
    <xsl:param name="UserId"/>
    <xsl:param name="records"/>
    <xsl:for-each select="$records[ns0:UserId/text() = $UserId]">
          <xsl:value-of select="ns0:rId"/>
          <xsl:value-of select="ns0:rName"/>





List out all the XML elements

I needed this for XSD documentation work. Generate a sample XML from the xsd and use that as  input to this xslt. It prints out all the elements in xpath format relative to root element.

<xsl:stylesheet version="1.0" xmlns:xsl="">

    <xsl:output method="text" indent="no" />

    <xsl:template match="*[not(*)]">
        <xsl:for-each select="ancestor-or-self::*">
            <xsl:value-of select="concat('.', substring-after(name(),':'))"/>

            <xsl:if test="count(preceding-sibling::*[name() = name(current())]) != 0">
                <xsl:value-of select="concat('[', count(preceding-sibling::*[name() = name(current())]) + 1, ']')"/>
        <xsl:apply-templates select="*"/>

    <xsl:template match="*">
        <xsl:apply-templates select="*"/>


Friday, February 12, 2016

Configure Weblogic ODL logger

How to configure weblogic ODL logger

Log files in the weblogic server could be managed using Log Configuration UI in the enterprise manager console (em console). We could configure rotation policies and log levels etc straight from the UI. Here are the steps to configure a custom ODL logger.


  • Goto em console http://host:port/em
  • Navigate to WebLogic Domain > DefaultDomain > DefaultServer
  • Rightclick on DefaultServer and select Logs > Log Configuration
  • Log Levels tab allows for log level configuration
  • Choose "Loggers with persistant log level state"
  • Scroll down to the bottom of the page and expand "Specify Loggers"
  • Enter the name of the class "" and choose log level (e.g. INFO)
  • Click on Apply button to save the settings.

  • Log files tab lets the user configure the log file handler for the selected log levels
  • Click on Create button
  • Enter the following details
    • Name: prasloghandler
    • Log path: ${domain.home}/servers/${weblogic.Name}/logs/${weblogic.Name}-pras.log
    • Log Level: INFO
    • Loggers to associate:
    • Choose a rotation policy based on your needs.
  • Click ok to finish.

Now everytime when a class in package uses java logging, it gets logged in the DefaultServer-pras.log file.

Here is an example java code

Java Example

import java.util.logging.Logger;

//Class variables
private static final Logger log = Logger.getLogger("");

//Code in methods"this is a test")