Sunday, June 05, 2011

search filter

find . -name "*jar" -print -exec jar -tvf {} \; | grep pattern ...

Thursday, April 21, 2011

Search for a class file in a set of jars

Lot of times we get the following errors:
Exception in thread "main" java.lang.NoClassDefFoundError: server

And we just don't know which jar file is missing from the classpath. And we need to know the correct jar file name(s) to fix the problem. So, here I create a shell script that would allow you to search through all the jar files by specifying a specific keyword. You may modify this script to search in all files (*) or whatever your criteria may be. This script works recursively for all sub-folders as well. So, you can keep this script on the root level of search and simply execute it.

=====================================
searchjars.sh
=====================================


#!/bin/sh

if [ $# -ne 1 ];
then
echo "Usage: ./searchjars.sh "
exit
fi

LOOK_FOR="$1"

for i in `find . -name "*jar"`
do
#echo "Looking in $i ..."
jar tvf $i | grep $LOOK_FOR > /dev/null
if [ $? == 0 ]
then
echo "==> Found \"$LOOK_FOR\" in $i"
fi
done


After saving this file, don't forget to give the execute permissions to this script.

[jboss@lin01 xlclient]$chmod +x searchjars.sh

Now you are ready to execute as follows:

If you don't specify any value, the script shows you the usage command:
[jboss@lin01 xlclient]$ ./searchjars.sh
Usage: ./searchjars.sh

When you specify the value to be searched, you will see the files that have that value in it.
[jboss@lin01 xlclient]$ ./searchjars.sh server
==> Found "server" in ./java/lib/rt.jar
==> Found "server" in ./ext/jdbcpool-0.99.jar
==> Found "server" in ./ext/nexaweb-nfc-api.jar
==> Found "server" in ./ext/jai_core.jar
==> Found "server" in ./ext/javagroups-all.jar
==> Found "server" in ./ext/jbossall-client.jar
==> Found "server" in ./ext/jboss-client.jar
==> Found "server" in ./ext/nexaweb-common.jar
==> Found "server" in ./ext/soap.jar
==> Found "server" in ./lib/xlVO.jar
==> Found "server" in ./lib/XellerateClient.jar
[jboss@lin01 xlclient]$

If you need to see what files are being looked at, uncomment (remove the #) the following line in the script:
#echo "Looking in $i ..."

Reference: http://rajnishbhatia19.blogspot.com/2008/10/searching-jar-files-in-unix-linux.html

Friday, April 01, 2011

KDE environment for Linux

Install Nomachine client, node and server on Linux machine and restart then
http://www.nomachine.com/download-package.php?Prod_Id=2519
Restart machine after this.

Install windows client on your laptop or desktop
http://www.nomachine.com/download-client-windows.php

Friday, March 18, 2011

linux rpm commands

For help, rpm --help or tar --help from the command line.

Install a package
rpm –ivh packagename

upgrade a package
rpm –Uvh packagename

create a tar file
tar –cvf myfiles.tar mydir/
(add z if you are dealing with or creating .tgz (.tar.gz) files)

standard install from source
tar –xvzf Apackage.tar.gz
cd Apackage
./configure
make
make install

Friday, February 25, 2011

Converting html character to actual character

Source : http://webglimpse.net/docs/howto_uml.html

#!/usr/local/bin/perl


# converts html files into ascii by just stripping anything between
# < and >
# written 4/21/96 by Michael Smith for WebGlimpse
#
# Added code to replace html codes for special chars with the
# characters themselves. 12/19/98 --GB
#
# Also add space in place of space-producing HTML tags
# 12/22/98 --GB

$carry=0;

while(){
$line = $_;

if($carry==1){
# remove all until the first >
next if($line!~s/[^>]*>//);
# if we didn't do next, it succeeded -- reset carry
$carry=0;
}

while($line=~s/(<[^\s>][^>]*>)/&addspace($1)/ge){};
if($line=~s/<[^\s>].*$//){
$carry=1;
}

$line = &fixspecial($line);
print $line;
}


sub addspace () {

$_ = shift;

# Check for tags that should NOT return a space
/(<\/?b>)|(<\/?i>)|(<\/?em>)|(<\/?font)|(<\/?strong)|(<\/?big)/i && return '';
/(<\/?sup)|(<\/?sub)|(<\/?u>)|(<\/?strike)|(<\/?style)/i && return '';

# Otherwise, put in a space
return ' ';

}


sub fixspecial () {

$_ = shift;

s/\ / /g;
s/\ / /g;
s/\¡/¡/g;
s/\¡/¡/g;
s/\¢/¢/g;
s/\¢/¢/g;
s/\£/£/g;
s/\£/£/g;
s/\¤/¤/g;
s/\¤/¤/g;
s/\¥/¥/g;
s/\¥/¥/g;
s/\¦/¦/g;
s/\¦/¦/g;
s/\§/§/g;
s/\§/§/g;
s/\¨/¨/g;
s/\¨/¨/g;
s/\©/©/g;
s/\©/©/g;
s/\ª/ª/g;
s/\ª/ª/g;
s/\«/«/g;
s/\«/«/g;
s/\¬/¬/g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