Grep Multi-line pattern between two words. find particular block from set of files.
The below shell script searches the list of java files in the current directory and try to look for the catch blocks that doesn't contain any logger initiated messages.
Ex file :
public class Download extends HttpServlet {
static final String sccsId = "%Z%%M% %I% %W% %G% %U%";
private static final PDLogger msgLogger = Logger.getCDSLoggerByName(Logger.PORTAL_LOGGER);
private static final String className = Download.class.getName();
static PublicKey anonymousPublicKey;
// standard anonymous public Key
static {
try {
KeyPairGenerator keyGen = null;
keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(1024);
KeyPair keyPair = keyGen.generateKeyPair();
anonymousPublicKey = keyPair.getPublic();
} catch (Exception ex) {
msgLogger.exception(Level.DEBUG_MIN, className, "{static}", ex);
}
}
}
static final String sccsId = "%Z%%M% %I% %W% %G% %U%";
private static final PDLogger msgLogger = Logger.getCDSLoggerByName(Logger.PORTAL_LOGGER);
private static final String className = Download.class.getName();
static PublicKey anonymousPublicKey;
// standard anonymous public Key
static {
try {
KeyPairGenerator keyGen = null;
keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(1024);
KeyPair keyPair = keyGen.generateKeyPair();
anonymousPublicKey = keyPair.getPublic();
} catch (Exception ex) {
msgLogger.exception(Level.DEBUG_MIN, className, "{static}", ex);
}
}
}
In the above file there is logger initiated message so, the script won't report any thing. But in case it won't find any keyword "logger" in catch block it reports the information.
Shell Script to recognize multi-line pattern :
Shell Script to recognize multi-line pattern :
#!/bin/sh
echo "Starting Recursive catch block search on the Dir : `pwd`"
fileCount=1
for i in `find . -name '*.java'`
do
echo "Working with file no:$fileCount and the file is:$i"
let fileCount="fileCount+1"
ttl=`cat $i | wc -l`
n=1
TTL=`cat $i | grep -c catch`
while read line
do
found=`echo $line | grep -i "catch" | sed 's/ //g' | cut -d "(" -f1`
if [ $found ]; then
while [ $n -le $TTL ]
do
begLineno=`grep -n catch $i | sed -n "$n"p | cut -d ":" -f1`
EndLineno=`sed = $i | sed 'N;s/\n/:/' | sed -n $begLineno,${ttl}p | grep -v "catch" | grep "}" | sed -n 1p | cut -d ":" -f1`
Logfound=`sed -n $begLineno,${EndLineno}p $i | grep -i Logger | sed 's/ //g' | cut -d "(" -f1 | sed -n 1p`
if [ $Logfound ]; then
echo "Logger message found In the $begLineno,$EndLineno Range Catch block" >> FoundLog.log
else
echo "No Logger messages(s)found In the $begLineno,$EndLineno Range Catch block in file $i" >> NotFound.log
fi
n=`expr $n + 1`
done
fi
done<$i
done
echo "Starting Recursive catch block search on the Dir : `pwd`"
fileCount=1
for i in `find . -name '*.java'`
do
echo "Working with file no:$fileCount and the file is:$i"
let fileCount="fileCount+1"
ttl=`cat $i | wc -l`
n=1
TTL=`cat $i | grep -c catch`
while read line
do
found=`echo $line | grep -i "catch" | sed 's/ //g' | cut -d "(" -f1`
if [ $found ]; then
while [ $n -le $TTL ]
do
begLineno=`grep -n catch $i | sed -n "$n"p | cut -d ":" -f1`
EndLineno=`sed = $i | sed 'N;s/\n/:/' | sed -n $begLineno,${ttl}p | grep -v "catch" | grep "}" | sed -n 1p | cut -d ":" -f1`
Logfound=`sed -n $begLineno,${EndLineno}p $i | grep -i Logger | sed 's/ //g' | cut -d "(" -f1 | sed -n 1p`
if [ $Logfound ]; then
echo "Logger message found In the $begLineno,$EndLineno Range Catch block" >> FoundLog.log
else
echo "No Logger messages(s)found In the $begLineno,$EndLineno Range Catch block in file $i" >> NotFound.log
fi
n=`expr $n + 1`
done
fi
done<$i
done
Tuesday, March 29, 2011
//
Labels:
Shell Scripting
//
0
comments
//
Since long time I know that there exists a eWAS which is express edition, but never played with it.
Today I got a chance to play with and deploy my project in it.
I got the installers from the below urls
http://bob.greenock.uk.ibm.com/tgl_build/embedded_products/ewas/7.0.0.7/EmbeddedExpress_wintel_ia32.zip
http://bob.greenock.uk.ibm.com/tgl_build/embedded_products/ewas/7.0.0.7/EmbeddedExpress_linux_ia32.zip
Installation :
It's simple zip file which will be extracted to desired location when we pass the path where it has to be
by running the below command
nc184197:/opt/builds/eWAS7 # ./install.sh -installRoot /opt/IBM/EWAS
+---------------------------------------+
+ EWAS Version 7.0 Install +
+---------------------------------------+
Validating target directory ...
Copying files ...
Setting permissions ...
Installation complete.
Now the next job is to create a profile :
nc184197:/opt/IBM/EWAS/bin # ./manageprofiles.sh -create -templatePath /opt/IBM/EWAS/profileTemplates/default/ -profileName AppSrv01 -profilePath /opt/IBM/EWAS/AppServer/AppSrv01
INSTCONFSUCCESS: Success: Profile AppSrv01 now exists. Please consult /opt/IBM/EWAS/AppServer/AppSrv01/logs/AboutThisProfile.txt for more information about this profile.
nc184197:/opt/IBM/EWAS/bin #
nc184197:/opt/IBM/EWAS/AppServer/AppSrv01/bin # ./startServer.sh server1
ADMU0116I: Tool information is being logged in file
/opt/IBM/EWAS/AppServer/AppSrv01/logs/server1/startServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: server1
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server server1 open for e-business; process id is 16248
I guess rest of the things are simple and same ...
To create secure profile in normal WAS -
[root@nc9118041006 bin]# ./manageprofiles.sh -create -templatePath /opt/IBM/WebSphere/AppServer/profileTemplates/default/ -profileName AppSrv02 -profilePath /opt/IBM/WebSphere/AppServer/profiles/AppSrv02 -enableAdminSecurity -adminUserName krishna -adminPassword krishna
Today I got a chance to play with and deploy my project in it.
I got the installers from the below urls
http://bob.greenock.uk.ibm.com/tgl_build/embedded_products/ewas/7.0.0.7/EmbeddedExpress_wintel_ia32.zip
http://bob.greenock.uk.ibm.com/tgl_build/embedded_products/ewas/7.0.0.7/EmbeddedExpress_linux_ia32.zip
Installation :
It's simple zip file which will be extracted to desired location when we pass the path where it has to be
by running the below command
nc184197:/opt/builds/eWAS7 # ./install.sh -installRoot /opt/IBM/EWAS
+---------------------------------------+
+ EWAS Version 7.0 Install +
+---------------------------------------+
Validating target directory ...
Copying files ...
Setting permissions ...
Installation complete.
Now the next job is to create a profile :
nc184197:/opt/IBM/EWAS/bin # ./manageprofiles.sh -create -templatePath /opt/IBM/EWAS/profileTemplates/default/ -profileName AppSrv01 -profilePath /opt/IBM/EWAS/AppServer/AppSrv01
INSTCONFSUCCESS: Success: Profile AppSrv01 now exists. Please consult /opt/IBM/EWAS/AppServer/AppSrv01/logs/AboutThisProfile.txt for more information about this profile.
nc184197:/opt/IBM/EWAS/bin #
nc184197:/opt/IBM/EWAS/AppServer/AppSrv01/bin # ./startServer.sh server1
ADMU0116I: Tool information is being logged in file
/opt/IBM/EWAS/AppServer/AppSrv01/logs/server1/startServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: server1
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server server1 open for e-business; process id is 16248
I guess rest of the things are simple and same ...
To create secure profile in normal WAS -
[root@nc9118041006 bin]# ./manageprofiles.sh -create -templatePath /opt/IBM/WebSphere/AppServer/profileTemplates/default/ -profileName AppSrv02 -profilePath /opt/IBM/WebSphere/AppServer/profiles/AppSrv02 -enableAdminSecurity -adminUserName krishna -adminPassword krishna
Tuesday, March 15, 2011
//
Labels:
Websphere
//
4
comments
//
While creating New databse If you are facing any of the below errors .. please follow the below solution.
db2inst1@nc184158:~/db2inst1/NODE0000/SQL00001> db2 -tf /opt/builds/DCD1321/MC/cds_db2_admin.sql
SQL1005N The database alias "CDSDB" already exists in either the local
database directory or system database directory.
SQL1013N The database alias name or database name "CDSDB" could not be found.
SQLSTATE=42705
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL1024N A database connection does not exist. SQLSTATE=08003
SQL0843N The server name does not specify an existing connection.
SQLSTATE=08003
SQL1013N The database alias name or database name "CDSDB" could not be found.
SQLSTATE=42705
SQL1005N The database alias "<name>" already exists
Solution
1. Db2 get dbm cfg | grep DFTDBPATH ( if unix , windows check for DFTDBPATH)
2. Db2 catalog db dbname on DFTDBPATH
3. Db2 terminate
4. Db2 drop db dbname
5. Then create db
db2inst1@nc184158:~/db2inst1/NODE0000/SQL00001> db2 -tf /opt/builds/DCD1321/MC/cds_db2_admin.sql
SQL1005N The database alias "CDSDB" already exists in either the local
database directory or system database directory.
SQL1013N The database alias name or database name "CDSDB" could not be found.
SQLSTATE=42705
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL1024N A database connection does not exist. SQLSTATE=08003
SQL0843N The server name does not specify an existing connection.
SQLSTATE=08003
SQL1013N The database alias name or database name "CDSDB" could not be found.
SQLSTATE=42705
SQL1005N The database alias "<name>" already exists
Solution
1. Db2 get dbm cfg | grep DFTDBPATH ( if unix , windows check for DFTDBPATH)
2. Db2 catalog db dbname on DFTDBPATH
3. Db2 terminate
4. Db2 drop db dbname
5. Then create db
How to change the location of Datable used by a Table space in Oracle?
Process to change the location of TABLE SPACE file in oracle :Note : The below steps are very sensitive; not run by normal users. It is recommended to run with the help of Oracle DBA prior taking backups. If any problem happens the old data might be lost.
1. Confirm and note down the existing Data file location for both CDS_TEMP_TS and CDS_TS by running the SQL commands.
Ex : current Data file locations are
- C:\ORACLE\PRODUCT\10.2.0\DB\DATABASE\CDS_TEMP_TS.DBF
- C:\ORACLE\PRODUCT\10.2.0\DB\DATABASE\CDS_TS.DBF
- SQL > shutdown immediate;
Ex : For new location of Data files.
- C:\DCD_DB\CDS_TEMP_TS.DBF
- C:\DCD_DB\CDS_TS.DBF
slplus sys as sysdba; Provide password and connect to idle instance.
5.start the Oracle and mount it with the below command
- SQL> startup mount;ORACLE instance started.Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 188746628 bytes
Database Buffers 415236096 bytes
Redo Buffers 7135232 bytes
Database mounted.
6. Now run the below commands at SQL> to associate the new data file location with database. - alter database rename file 'C:\oracle\product\10.2.0\db\database\CDS_TEMP_TS.DBF' to 'C:\DCD_DB\CDS_TEMP_TS.DBF';
- alter database rename file 'C:\oracle\product\10.2.0\db\database\CDS_TS.DBF' to 'C:\DCD_DB\CDS_TS.DBF';
- alter database open;
- sqlplus "sys/oracle@orcl as sysdba"
- SQL> select tablespace_name,file_name from dba_temp_files where tablespace_name LIKE 'CDS%';
- SQL> select tablespace_name,file_name from dba_data_files where tablespace_name LIKE 'CDS%';
Where are Oracle logs Reflecting this ?
SQL> show parameter dump;
NAME TYPE VALUE
----------------------------------
background_core_dump string partial
background_dump_dest string C:\ORACLE\PRODUCT\10.2.0\ADMIN
\ORCL\BDUMP
core_dump_dest string C:\ORACLE\PRODUCT\10.2.0\ADMIN
\ORCL\CDUMP
max_dump_file_size string UNLIMITED
shadow_core_dump string partial
user_dump_dest string C:\ORACLE\PRODUCT\10.2.0\ADMIN
\ORCL\UDUMP
SQL>
C:\ORACLE\PRODUCT\10.2.0\ADMIN\ORCL\bdump
check the " alert_orcl.log " which shows the commands and details used to create CDS_TEMP_TS and CDS_TS.
Reference : http://www.orafaq.com/wiki/Move_datafile_to_different_location
How to Unlock BSNL 3G data card to use it with Airtel and Vodafone Model no : LW272 ?
How to unlock BSNL 3G data card( Model no : LW272 )use it with Airtel and Vodafone TATA DOCOMO etc.
I have purchased my BSNL 3G device ( Model no : LW272 ) in the start of year 2009, during this time no other providers were not available in the 3G market.
But time changes and slowly players like Docomo, Airtel and Vodafone etc guys entering market. So I was curious to know/try whether the same BSNL USB Data card can help me if I would like to shift to new operator in future. Luckly my device is not Hardware locked but it is just software locked. If it is hardware locked also we need to flash the memory.
In this BSBL 3G teracome device model no LW272 it is just interface software locked. Thats why it shows " Unauthorised sim, your modem will get closed now" .
So I tried the below steps and worked fine for me with vodafone 2G using Vodafone Mobile connect plan.(Post paid 350/month unlimited).
1. Install BSNL 3G software initially comes with the device to support the modem by installing the drivers.
2. Then check if you have still BSNL 3G sim working whether is connecting or not.
3. Once it is working as expected , go to the install location of BSNL 3G device software Ex : C:\Program Files\BSNL 3G Data Card\BSNL 3G and rename the BSNL 3G.exe to some thing else.
To prevent it running from the start of device.
4. Now create one new dial up connection by selecting the device HSPA DataCardPropritary USB MODEM
5. while creating dialup connection use dialing number *99# ; user name and password will be blank. (depending on the signal provider dialing number might change; but for Vodafone *99# is working)
6. Now disconnect the device and remove BSNL sim and keep the other sim card ex : Vodafone.
7. Just wait for 30 sec till the 3G usb LED glows to Green. Unless it glows green you cant do any thing.
8. Now just click connect for the dialup you created already.
9. Now you are all set to use the BSNL device for other operators also.
10. enjoy your Internet now !
Hopefully same steps hold good for Vodafone 3G also which is coming soon !
I have purchased my BSNL 3G device ( Model no : LW272 ) in the start of year 2009, during this time no other providers were not available in the 3G market.
But time changes and slowly players like Docomo, Airtel and Vodafone etc guys entering market. So I was curious to know/try whether the same BSNL USB Data card can help me if I would like to shift to new operator in future. Luckly my device is not Hardware locked but it is just software locked. If it is hardware locked also we need to flash the memory.
In this BSBL 3G teracome device model no LW272 it is just interface software locked. Thats why it shows " Unauthorised sim, your modem will get closed now" .
So I tried the below steps and worked fine for me with vodafone 2G using Vodafone Mobile connect plan.(Post paid 350/month unlimited).
1. Install BSNL 3G software initially comes with the device to support the modem by installing the drivers.
2. Then check if you have still BSNL 3G sim working whether is connecting or not.
3. Once it is working as expected , go to the install location of BSNL 3G device software Ex : C:\Program Files\BSNL 3G Data Card\BSNL 3G and rename the BSNL 3G.exe to some thing else.
To prevent it running from the start of device.
4. Now create one new dial up connection by selecting the device HSPA DataCardPropritary USB MODEM
5. while creating dialup connection use dialing number *99# ; user name and password will be blank. (depending on the signal provider dialing number might change; but for Vodafone *99# is working)
6. Now disconnect the device and remove BSNL sim and keep the other sim card ex : Vodafone.
7. Just wait for 30 sec till the 3G usb LED glows to Green. Unless it glows green you cant do any thing.
8. Now just click connect for the dialup you created already.
9. Now you are all set to use the BSNL device for other operators also.
10. enjoy your Internet now !
Hopefully same steps hold good for Vodafone 3G also which is coming soon !
Referecne : [1] [2]
Special Thanks to http://www.dreamit.co.in/
This post main aim is to redirect the SQL select query output to a file for example to make a simple HTML file to display the select query output.
In this example I created two sample files one is 1.sh and another one is select.sh
File 1:
bash-3.00# cat 1.sh
sqlplus PV_ADMIN/PV@PV<< EOF
@select.sql
exit
EOF
sqlplus PV_ADMIN/PV@PV<< EOF
@select.sql
exit
EOF
File 2 :
bash-3.00# cat select.sql
set linesize 200
set pages 1000
set feedback off
set markup html on spool on
spool test.html
select * from PV_REPORT.AGINFO;
spool off;
set linesize 200
set pages 1000
set feedback off
set markup html on spool on
spool test.html
select * from PV_REPORT.AGINFO;
spool off;
so when I run the 1.sh it simply calls select.sh to spool the output to a test.html which will contain the select of the required SQL query.
Another simple file
bash-3.00# cat selctftp.sh
#!/bin/sh
#
# This script will make connection to Proviso DB
# and selects the data required from a particular
# table to populate it in a file and uploads to
# your target server
#
#
NOW=`(date +"%b-%d-%y")`
echo $NOW
echo "$0 Running on $NOW"
LOGFILE="log-$NOW.log"
echo $LOGFILE
su - oracle <
id
sqlplus PV_ADMIN/PV@PV
set wrap off
spool $LOGFILE
select * from PV_REPORT.AGINFO;
sppol off
quit
kk
bash-3.00# cat selctftp.sh
#!/bin/sh
#
# This script will make connection to Proviso DB
# and selects the data required from a particular
# table to populate it in a file and uploads to
# your target server
#
#
NOW=`(date +"%b-%d-%y")`
echo $NOW
echo "$0 Running on $NOW"
LOGFILE="log-$NOW.log"
echo $LOGFILE
su - oracle <
id
sqlplus PV_ADMIN/PV@PV
set wrap off
spool $LOGFILE
select * from PV_REPORT.AGINFO;
sppol off
quit
kk
Popular Posts
-
The best solution to know about these init levels is to understand the " man init " command output on Unix. There are basically 8...
-
How to Unlock BSNL 3G data card to use it with Airtel and Vodafone Model no : LW272 ? How to unlock BSNL 3G data card( Model no : LW272 )us...
-
How to transfer bike registration from one State to other (Karnataka to Andhra)?? Most of us having two wheelers purchased and registered in...
-
Latest Post on ETV D3 Old Post on ETV D1 D2 link ETV Dhee 3 - D3 - Enjoy maadi ETV Dhee feedback link - Direct ETV site use this...
-
ఓం శ్రీ స్వామియే శరణం ఆయ్యప్ప!! Related posts : Trip to Sabarimala - Part 1 Trip to Sabarimala - Part 2 Ayappa Deeksha required things...
Popular posts
- Airtel and vodafone GPRS settings for pocket PC phones
- Andhra 2 America
- Ayyappa Deeksha required things
- Blogs I watch !
- Captions for your bike
- DB2 FAQs
- Deepavali Vs The Goddes of sleep
- ETV - Dhee D2 D3
- Evolution of smoking in India Women
- How to make credit card payments?
- init 0, init 1, init 2 ..
- Java-J2EE interview preparation
- mCheck Application jar or jad download
- My SQL FAQs
- My Travelogues
- Old is blod - New is italic
- Online pay methids for credit cards
- Oracle FAQs
- Pilgrimages
- Smoking in Indian Women
- Technology Vs Humans
- Twitter feeds for all Telugu stars on single page.
- Unix best practices
- Unix FAQs
