Oct 12, 2011

malformed header from script. - CGI Bash

A CGI bash script will throw error as malformed header from script. in the web server error log when the content is not spaced, To eliminate this error give a empty line/newline after content.

#!/bin/bash
echo "Content-type: text/html"
echo
the log may look like this,
[Tue Oct 11 14:09:42 2011] [error] [client 172.16.32.215] malformed header from script. Bad header=TEST: test.html

Sep 25, 2011

Locking windows xp/vista in command line

Found this command when i tried to lock my remote PC (xp), its useful when you need to lock your VM or remote desktops. 

rundll32.exe user32.dll, LockWorkStation


Note: this is case sensitive, otherwise will give dll errors.

May 10, 2011

Create full format Excel file from bash scripts

This post shows how I managed to create a excel output with all the bells and whistles of the MS Excel such as merging, colors on the tables and etc.
Open your excel sheet if you have already or make a template of your needed output format.
 



Save it as XML Spreadsheet 2003 .xml format in your drive.





Ignore the following pop up and hit Yes.

 


Open the saved xml with your favorite editor, in my case Notepad++.
 


Now you can see your data filled inside <Table> tag. you can simply parse the data from your real output and replce the start and end with these Tags " <Cell ss:StyleID="s62"><Data ss:Type="Number">" and "</Data></Cell>" then write the whole data in a excel file (something.xls). In my case i have parsed a file for the numbers output and replced the start and end with the xml tags.

Eg: grep "Selected Period" PV.html|sed -ne 's/^.*Selected Period\([^T]*\).*$/\1/p'| sed 's/\\//g;s/nt*//g;s/\///g;s/\&bsp;//g;s/<[^>]*>/\n/g'|sed 's/[0-9]\.//g;s/^ //g;/^$/d;/[a-z].*/d;s/^/\<Cell ss\:StyleID="s112"\>\<Data ss\:Type="Number"\>/g;s/$/\<\/Data\>\<\/Cell\>/g' > opv.dat




Hope this helps to create an excel from Bash.

Happy Scripting.
Deva.

Mar 12, 2011

Unix host disk usage HTML report

Below can provide the disk usage from multiple hosts in a HTML format report sorted with usage percentage.

Echo “From: Deva
To: someone@mail.com
MIME-Version: 1.0
Content-Type: text/html
Subject: Disk_usage" > te12
 
check_lvnodes 'df -g |sed "s/^/`hostname`_/g"' > teak;check_lvwebs 'df -g|sed "s/^/`hostname`_/g"' >> teak;
\(cat te12;echo "

";sort -nr -k4 teak |awk -F" " '$4 > 50'|head -300|sed '/Mounted/d;s/  */ /g;s/ /\&lt
\;\/td\>\/g;s/$/\<\/td\>\<\/tr\>/g;s/^/\\/')|sendmail –t    
DevtotalFreeUsedIfreeIUsedMount

Starting multiple JVMs through ssh

If you ssh auto is enabled from a central server, starting multiple jvms on several nodes is easy. Below shows for two jvms per node,


for sv in ccaita1k ccaita1l ccaita1m ccaita1n ccaita67 ccaita69 ccaita7p ccaita7q ccaita7r ccaita7x ccaita7y ccaita8k ccaita8l ccaitack; do
ssh $sv 'cd /opt/isv/WAS51/AppServer/bin; ./startServer.sh WC_THD_`hostname` -nowait; ./startServer.sh WC_THD2_`hostname` -nowait'
done

JVM startup issues

When you have trouble starting the jvm, use -trace with startserver.sh. Its not the runtime trace, but startup trace. It will print more logs for the JVM startup so that you can find out where its failing.

 

 

[3/9/11 20:56:05:916 EST] 4f6d7907 UnixProcessIm > create() : Calling for a process create.

[3/9/11 20:56:05:923 EST] 4f6d7907 UnixProcessIm d Creation params are: [executable:] /opt/isv/WAS51/AppServer/java/bin/java [command line args:] -Djava.net.preferIPv4S

tack=true -Dwas.status.socket=48508 -Xbootclasspath/p:/opt/isv/WAS51/AppServer/java/jre/lib/ext/ibmorb.jar:/opt/isv/WAS51/AppServer/java/jre/lib/ext/ibmext.jar -classpa

th /opt/isv/WAS51/AppServer/properties:/opt/isv/WAS51/AppServer/properties:/opt/isv/WAS51/AppServer/lib/bootstrap.jar:/opt/isv/WAS51/AppServer/lib/j2ee.jar:/opt/isv/WAS

51/AppServer/lib/lmproxy.jar:/opt/isv/WAS51/AppServer/lib/urlprotocols.jar -verbose:gc -Xms256m -Xmx1536m -Dws.ext.dirs=/opt/isv/WAS51/AppServer/java/lib:/opt/isv/WAS51

/AppServer/classes:/opt/isv/WAS51/AppServer/classes:/opt/isv/WAS51/AppServer/lib:/opt/isv/WAS51/AppServer/lib/ext:/opt/isv/WAS51/AppServer/web/help:/opt/isv/WAS51/AppSe

rver/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime -Dserver.root=/opt/isv/WAS51/AppServer -Ddb2j.system.home=/opt/isv/WAS51/AppServer/cloudscape -Duser.instal

l.root=/opt/isv/WAS51/AppServer -Dcom.ibm.itp.location=/opt/isv/WAS51/AppServer/bin -Dwas.install.root=/opt/isv/WAS51/AppServer -Dibm.websphere.preload.classes=true -Dc

om.ibm.wca.logging.configFile=/opt/isv/WAS51/THDCommerceServer561/instances/THD/xml/loader/WCALoggerConfig.xml -Dcom.ibm.websphere.ejbcontainer.FbpkAlwaysReadOnly=true

-Dcom.ibm.ws.cache.flushToDiskOnStop=false -Dcom.ibm.commerce.dynacache.decrypt=false -Dcom.ibm.servlet.file.esi.timeOut=0 -Dcom.ibm.ws.cache.CacheConfig.htodDelayOfflo

adEntriesLimit=100000 -Dcom.ibm.websphere.ejbcontainer.allowEarlyInsert=true -Dcom.ibm.ws.cache.CacheConfig.diskCacheEvictionPolicy=1 -Dcom.ibm.ws.cache.CacheConfig.dis

kCachePerformanceLevel=3 -Dcom.ibm.ws.cache.CacheConfig.diskCacheSizeInGB=10 -Dorg.apache.taglibs.standard.lang.jstl.maxExpCacheSize=10000 -Dcom.ibm.commerce.scheduler.

SchedulerHostName=ccaita7w_2 -Dcom.ibm.ws.cache.CacheConfig.diskCacheHighThreshold=95 -Dcom.ibm.ws.cache.CacheConfig.diskCacheLowThreshold=85 -Dam.home=/opt/isv/WAS51/I

TCAM/DC/itcamdc -Dcom.ibm.tivoli.jiti.injector.ProbeInjectorManagerChain.primaryInjectorFile=/opt/isv/WAS51/ITCAM/DC/runtime/was51.ccaita7w.WC_THD2_ccaita7w/probeinject

ormanagerchain.properties -verbose:gc -Xk32000 -Xp20480k,100k -DinvocationCacheSize=0 -DjvmName=WC_THD2_ccaita7w -Xgcpolicy:subpool -Xtlhs768 -Djava.awt.headless=true -

Djava.security.auth.login.config=/opt/isv/WAS51/AppServer/properties/wsjaas.conf -Djava.security.policy=/opt/isv/WAS51/ITCAM/DC/runtime/was51.ccaita7w.WC_THD2_ccaita7w/

was51.ccaita7w.WC_THD2_ccaita7w.datacollector.policy com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer /opt/isv/WAS51/AppServer/config CommerceNetwork ccaita7

w WC_THD2_ccaita7w [environment:] EXTSHM=ON AIXTHREAD_MUTEX_DEBUG=OFF AIXTHREAD_ENRUSG=OFF AIXTHREAD_SCOPE=S AIXTHREAD_RWLOCK_DEBUG=OFF AIXTHREAD_COND_DEBUG=OFF QUALDIR

=ccaita7w.WC_THD2_ccaita7w _JVM_THREAD_DUMP_BUFFER_SIZE=25000000 IBM_HEAPDUMP=false IBM_HEAP_DUMP=false IBM_HEAPDUMPDIR=/opt/isv/WAS51/AppServer/logs/WC_THD2_ccaita7w I

BM_HEAPDUMP_OUTOFMEMORY=true IBM_JAVADUMP_OUTOFMEMORY=true IBM_JAVA_HEAPDUMP_TEXT=true JITC_COMPILEOPT_unused=COMPILING(TIME):RECOMPILING LIBPATH=/opt/isv/WAS51/ITCAM/D

C/toolkit/lib/aix4-r1: [user ID:] tauser02 [group ID:] www [working directory:] /opt/isv/WAS51/THDCommerceServer561 [umask:] 22 [Standard out/err filenames:] null /opt/

isv/WAS51/AppServer/logs/WC_THD2_ccaita7w/native_stdout.log /opt/isv/WAS51/AppServer/logs/WC_THD2_ccaita7w/native_stderr.log [priority:] 20 [process group:] 0 [process

name:] WC_THD2_ccaita7w [inheritParentStreams:] false[detachProcess:] false

[3/9/11 20:56:05:986 EST] 4f6d7907 UnixProcessIm < create() : Process created.

[3/9/11 20:56:05:987 EST] 4f6d7907 UnixProcessIm > id() : Obtaining process ID.

[3/9/11 20:56:05:987 EST] 4f6d7907 UnixProcessIm > checkNativeHandle() : Checking validity of nativeHandle.

[3/9/11 20:56:05:987 EST] 4f6d7907 UnixProcessIm < checkNativeHandle() : Done checking validity of nativeHandle.  Appears valid.

[3/9/11 20:56:05:987 EST] 4f6d7907 UnixProcessIm < id() : Obtained process ID: 880908

[3/9/11 20:56:05:988 EST] 4f6d7907 AdminTool     A ADMU3200I: Server launched. Waiting for initialization status.

[3/9/11 20:56:05:999 EST] 587eb907 UnixProcessIm > ping() : Checking to see if a process exists.

[3/9/11 20:56:06:037 EST] 587eb907 UnixProcessIm > checkNativeHandle() : Checking validity of nativeHandle.

[3/9/11 20:56:06:038 EST] 587eb907 UnixProcessIm < checkNativeHandle() : Done checking validity of nativeHandle.  Appears valid.

[3/9/11 20:56:06:039 EST] 587eb907 UnixProcessIm < ping() : Done with existance check

[3/9/11 20:56:06:039 EST] 587eb907 UnixProcessIm > waitForTermination() : Requesting to wait for process termination

[3/9/11 20:56:06:039 EST] 587eb907 UnixProcessIm > checkNativeHandle() : Checking validity of nativeHandle.

[3/9/11 20:56:06:039 EST] 587eb907 UnixProcessIm < checkNativeHandle() : Done checking validity of nativeHandle.  Appears valid.

[3/9/11 20:57:20:446 EST] 4f6d7907 AdminTool     A ADMU3000I: Server WC_THD2_ccaita7w open for e-business; process id is 880908

[3/9/11 20:57:20:447 EST] 4f6d7907 AdminTool     d Returning from executeUtility method with return code: 0



Deva
-Sent from my iPad