Unix :
find . -type f -name '*.jar' -print0 | xargs -0 -I '{}' sh -c 'jar tf {} | grep com/sun/net/ssl/HostnameVerifier.class && echo {}'
find . -type f -name '*.jar' -print0 | xargs -0 -I '{}' sh -c 'jar tf {} | grep HostnameVerifier.class && echo {}'
Ex :
[kg6378@bldv0014 jdk1.6.0_20]$ find . -type f -name '*.jar' -print0 | xargs -0 -I '{}' sh -c 'jar tf {} | grep com/sun/net/ssl/HostnameVerifier.class && echo {}'
com/sun/net/ssl/HostnameVerifier.class
./jre/lib/jsse.jar
[kg6378@bldv0014 jdk1.6.0_20]$ find . -type f -name '*.jar' -print0 | xargs -0 -I '{}' sh -c 'jar tf {} | grep HostnameVerifier.class && echo {}'
com/sun/deploy/security/CertificateHostnameVerifier.class
./jre/lib/deploy.jar
javax/net/ssl/HostnameVerifier.class
javax/net/ssl/HttpsURLConnection$DefaultHostnameVerifier.class
sun/net/www/protocol/https/DefaultHostnameVerifier.class
com/sun/net/ssl/HostnameVerifier.class
./jre/lib/jsse.jar
Windows :
forfiles /S /M *.jar /C "cmd /c jar -tvf @file | findstr /C:"HostnameVerifier.class" && echo @path"
C:\Users\kg6378\Desktop\jdk-7u79-windows-x64\tools>cd C:\Krish\MyDocs\SWS\Jdk1.6
.0_14
C:\Krish\MyDocs\SWS\Jdk1.6.0_14>forfiles /S /M *.jar /C "cmd /c jar -tvf @file |
findstr /C:"HostnameVerifier.class" && echo @path"
3517 Thu May 21 09:19:20 EDT 2009 com/sun/deploy/security/CertificateHostnameV
erifier.class
"C:\Krish\MyDocs\SWS\Jdk1.6.0_14\jre\lib\deploy.jar"
194 Thu Feb 05 13:54:20 EST 2009 javax/net/ssl/HostnameVerifier.class
618 Thu Feb 05 13:54:22 EST 2009 javax/net/ssl/HttpsURLConnection$DefaultHost
nameVerifier.class
384 Thu Feb 05 13:54:22 EST 2009 sun/net/www/protocol/https/DefaultHostnameVe
rifier.class
272 Thu Feb 05 13:54:32 EST 2009 com/sun/net/ssl/HostnameVerifier.class
"C:\Krish\MyDocs\SWS\Jdk1.6.0_14\jre\lib\jsse.jar"
C:\Krish\MyDocs\SWS\Jdk1.6.0_14>
1. How to get the absolute or full path while calling another shell script from one shell script.
#!/bin/sh
source $(readlink -f "ifix_config.sh") uninstall
The above code snippet calls another shell script by name ifix_config.sh. which is available in the same directory of current script.
Abosolute path will be used with the readlink -f option there. uninstall isa parameter passed to it.
2. How to check how many parameters are passed in to a shell script..
if [ $# != "1" ]; then$# represents total number of parameters passed to a shell script when called.
echo "Usage: ifix_config.sh install or ifix_config.sh uninstall"
exit
else
....
....
In the above example code if at least one parameter is not passed it throws a message and exits.
3. How to check if a variable is set or not . How to check if a viariale has empty string ?
LOCALE_CODE=$LANG
if [ -z $LOCALE_CODE ];
then JAZZSM_SYSTEM_LOCALE="en_US"
fi
In the above example snippet we are setting some value for LOCALE_CODE if in case it is not set for some reason -z option with if condition returns true
so in above example if it( if [ -z $LOCALE_CODE ] ) is true it will set it to en_US
4. How to get the parent directory path of a file or directory ?
PresentDir=`dirname $PWD`
When dirname is given a pathname, it will delete any suffix beginning with the last slash ('/') character and return the result.
For example:
$ dirname /usr/home/carpetsmoker/dirname.wiki
/usr/home/carpetsmoker
5. How to get the only filename when absolute path is given ?
Example
$ basename /home/jsmith/base.wiki
base.wiki
$ basename /home/jsmith/base.wiki .wiki
base
IFIX_NO=`basename $PWD`
0001
6. How to read a properties file in shell script ?
# Reading settings.properties to find IM Install location
IM_HOME=`sed '/^\#/d' $PropertiesFile | grep 'product.install.location' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
echo IM Install Location is : $IM_HOME
Example :
$PropertiesFile contents are like below ..
-------------------------------------------
#Fri, 01 Mar 2013 02:59:37 -0500
product.was.user=smadmin
product.jdbc.lib.path=/opt/IBM/JazzSM/lib/db2
product.data.location=/var/ibm/InstallationManager
product.install.location=/opt/IBM/InstallationManager/eclipse
-------------------------------------------
The while process is to Scan through the file to get an individual property
This works well if you just want to read a specific property in a Java-style properties file. Here's what it does:
* Remove comments (lines that start with '#') >> sed '/^\#/d' myprops.properties
* Grep for the property >> grep 'someproperty'
* Get the last value using >> tail -n 1
* Strip off the property name and the '=' (using {{cut -d "=" -f2-}) to handle values with '=' in them).
sed '/^\#/d' myprops.properties | grep 'someproperty' | tail -n 1 | cut -d "=" -f2-
It can also be handy to strip off the leading and trailing blanks with this sed expression:
s/^[[:space:]]*//;s/[[:space:]]*$//
Which makes the whole thing look like this:
sed '/^\#/d' myprops.properties | grep 'someproperty' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
Reference
7. How to check file existance before running it ?
[ -f "$SCRIPT_LOCATION/myshellscript.sh" ] && . "$SCRIPT_LOCATION/myshellscript.sh"
Having quotes for the file path eliminates issues arise out of spaces in the path.
8. How to read input values through shell script ?
# Ask for WAS credentials
if [ -z "${JAZZSM_WAS_USERNAME}" ]
then
echo -n "${wasUserNamePrompt}: "
read JAZZSM_WAS_USERNAME
fi
echo -n "${wasUserNamePrompt}: " >> it helps to prompt user with particular string before commandline prompt while running shell script, in order to resolve wasUserNamePrompt string we need to run its correspinding properties file before this call .
For example config_messages.sh has text like below , and when it is run before the above command it will resolve this value.
#!/bin/sh
#NLS_MESSAGEFORMAT_NONE
#NLS_ENCODING=UTF-8
wasUserNamePrompt="Enter the Websphere Application Server user name:"
wasPasswordPrompt="Enter the Websphere Application Server password:"
and U want to mount them to two different directories which are freshly created under /mnt like below .. .WAS_ISO and JAZZ_ISO
AIX :
IBM-jazzsm-launchpad-1.1-aix64.iso IBM-was-8.5.0.1-aix64.iso
bash-3.2# loopmount -i IBM-jazzsm-launchpad-1.1-aix64.iso -o "-V cdrfs -o ro" -m /mnt/JAZZ_ISO/
bash-3.2# loopmount -i IBM-was-8.5.0.1-aix64.iso -o "-V cdrfs -o ro" -m /mnt/WAS_ISO/
bash-3.2#
Linux :
1) Create the directory i.e. mount point:
# mkdir -p /mnt/disk
2) Use mount command as follows to mount iso file called disk1.iso:
# mount -o loop disk1.iso /mnt/disk
--
Thanks & Regards
Krishna
http://www.krishnababug.com/
set -x
if [[ "$1" == "start" || "$1" == "-start" ]]; then
echo "code for start action"
else
echo "Please input valid arguments"
echo "Usuage: setup.sh start or setup.sh -start "
exit
fi
The below simple shell script will automate the FTP steps, to upload file(s) from one machine to other easily ...
edit it according to ur convinece ..
#!/bin/bash
HOST='9.142.193.94'
USER='root'
PASSWD='havefun'
ftp -i -n $HOST <<kris
user ${USER} ${PASSWD}
binary
cd /opt
put cds_db2_admin.sql
quit
kris
nc184120:/opt/builds # ./ftp.sh
Connected to virgo.in.ibm.com.
220-FTP Server (user 'krishna.g@in.ibm.com')
220
331-Password:
331
230-230 User root logged in.
230
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
250 CWD command successful.
local: cds_db2_admin.sql remote: cds_db2_admin.sql
229 Entering Extended Passive Mode (|||64693|)
150 Opening BINARY mode data connection for cds_db2_admin.sql.
100% |**************************************************************************************************************************************| 1101 6.73 MB/s 00:00 ETA
226 Transfer complete.
1101 bytes sent in 00:00 (4.48 KB/s)
221-You have transferred 1101 bytes in 1 files.
221-Total traffic for this session was 1601 bytes in 1 transfers.
221-Thank you for using the FTP service on virgo.
221 Goodbye.

Basically I want to check whether a directory has the read write permissions for the user?
I am using here a simple commonsense that a read write permissions will make the octal permissions of it more than 600 for sure .. that's it.
d rwx rwx rwx
d rw- --- ---
420 000 000
6 0 0
rwx r-x r-x
7 5 5
So it should be always greater than 600 for a directory to have read write permissions always.
Basically I'm using stat tool to find the permissions of a dir
Ex : check stat for /opt/a
nc184120:/opt # stat /opt/a
File: `/opt/a'
Size: 48 Blocks: 0 IO Block: 4096 directory
Device: 802h/2050d Inode: 101912 Links: 2
Access: (0155/d--xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-07-01 22:53:59.845347264 -0700
Modify: 2010-07-01 01:45:43.769709152 -0700
Change: 2010-07-01 01:46:14.790993200 -0700
So the above script doesn't have read or write permissions.
Shell script :
dir="/opt/a"
echo "Checking the permissions for $dir"
stat $dir
echo "##############################################"
if [ `stat -c "%a" $dir` -ge 600 ] ; then
echo "$dir has Read Write permissions."
else
echo "$dir has no read write permissions."
fi
and the output looks like below ...
nc184120:/opt # ./per.sh
Checking the permissions for /opt/a
File: `/opt/a'
Size: 48 Blocks: 0 IO Block: 4096 directory
Device: 802h/2050d Inode: 101912 Links: 2
Access: (0155/d--xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-07-01 22:53:59.845347264 -0700
Modify: 2010-07-01 01:45:43.769709152 -0700
Change: 2010-07-01 01:46:14.790993200 -0700
##############################################
/opt/a has no read write permissions.

The following small shell script will generate a SQL file which contains multiple insert statements.
The shell script will add unique numbers for each primary key object in the insert statements.
######################################################################Put the above lines of code in shell script and run it at the shell to generate mutiple insert statements according to ur need in the SQL file dummydata.sql
i=1270803816866
k=1
while [ $k -le 4 ]
do
echo "insert into CDSSCHEMA.PLAN_DESCRIPTION (PLAN_ID,PACKAGE_ID,LOCAL_IP,REMOTE_IP,STATUS,PLANCREATIONTIME,USERID) values ('$i','1270803791784','9.124.158.200','9.124.158.200',1,'2010-04-09 09:04:21.979898','CDS_Administrator')" >> dummydata.sql
let i="i+1"
let k="k+1"
done
####################################################################
Don't forget to add your better ideas to improve this script in form of comments.

1.To count the number of words in a string which are separated with special charters like ,
# echo "apple,mango,orange,goa" | awk -F, '{print NF}'2.How to create and print the continuous variables in a loop after assigning the values to them
4
i=03.in the nslookup <IP> output print only Valid hostname of that IP
temp="MYTEMP"
echo $temp
while [ $i -le 4 ]
do
let i="i+1"
eval DYNVAR${i}=$temp$i
eval echo "Value in DYNVAR$i is \$DYNVAR$i "
done
nc041031:~ # nslookup 9.48.185.207 | awk '/=/ {print $4}'4.in nslookup <Hostname> print only the valid IP of the corresponding host
nc185207.tivlab.austin.ibm.com.
nc041031:~ # nslookup nc185207.tivlab.austin.ibm.com. | awk '/Address:/ {print $2}' | grep -v "#"5.Cont ...
9.48.185.207
Technorati Tags: awk.sed, shell scripting, unix, one liners


Why do we need RAC ? With Oracle RAC we can enable Single Database to run across cluster of servers. If one fails the other will be able to manage the user requests.It allows multiple nodes in a clustered system to mount and open a single database that resides on shared disk storage. Even if the service fails on one system(node) the database services will be available from other remaining nodes. In a non RAC Database the services will be available only on one system, so if the system fails the DB services will be down (single point of failures).
What is cluster ?
A cluster consists of two or more computers working together to provide
a higher level of availability, reliability, and scalability than can
be obtained by using a single computer.
Hardware requirements for Oracle 11gR2 RAC?
* A dedicated network interconnect - might be as simple as a fast network connection between nodes; and
* A shared disk subsystem.
two CPUs, 1GB RAM, two Gigabit Ethernet NICs, a dual channel SCSI host bus adapter (HBA), and eight SCSI disks connected via copper to each host (four disks per channel). The disks were configured as Just a Bunch Of Disks (JBOD)—that is, with no hardware RAID controller.
Ex :
1 cpu
2 GB memory
18 GB local disk with OS
10 GB local disk for Oracle binaries
3 x 10 GB shared disks for RAC
Software Requiremnts for Oracle 10 g RAC ?
1. An operating system
2. Oracle Clusterware
3. Oracle RAC software
4. An Oracle Automatic Storage Management (ASM) instance (optional).
What are the supported operating systems and platforms for Oracle RAC ?
* Windows Clusters
* Linux Clusters
* Unix Clusters like SUN PDB (Parallel DB).
* IBM z/OS in SYSPLEX
* HP Serviceguard extension for RAC
Many other platforms and operating systems are supported refer documentation of product.
References :
http://download.oracle.com/docs/cd/B28359_01/install.111/b28264/toc.htm
http://www.oracle.com/technology/software/products/database/index.html
http://www.oracle.com/technology/pub/articles/smiley_rac10g_install.html
http://www.oracle-base.com/articles/11g/OracleDB11gR1RACInstallationOnLinuxUsingNFS.php
http://www.oracle.com/database/rac_home.html
http://www.oracle.com/technology/products/database/clustering/index.html
http://startoracle.com/2007/09/30/so-you-want-to-play-with-oracle-11gs-rac-heres-how/
http://www.orafaq.com/wiki/RAC_FAQ


file 1 :
apple goa orange
hello hi how are you
file 2 :
mango goa orange apple
how are you hi hello
Final out put required is :
apple goa orange mango
hello hi how are you
Screen outputs :
nc041031:/opt/krish # cat 1.txt
apple goa orange
hello hi how are you
nc041031:/opt/krish # cat 2.txt
mango goa orange apple
how are you hi hello
nc041031:/opt/krish # cat merge.sh
#!/bin/shnc041031:/opt/krish # ./merge.sh
awk 'NR==FNR{a[FNR]=$0;next} {print a[FNR],$0}' 1.txt 2.txt | tee a.txt
awk '{ while(++i<=NF) printf (!a[$i]++) ? $i FS : ""; i=split("",a); print "" }' a.txt | tee final.txt
apple goa orange mango goa orange apple
hello hi how are you how are you hi hello
apple goa orange mango
hello hi how are you
nc041031:/opt/krish # cat final.txt
apple goa orange mango
hello hi how are you
For all of them i suggest strongly one thing try to use df command as like below first
df -h
tvt2086:/products/WAS64ZLX # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dasda1 4.2G 3.8G 347M 92% /
udev 1001M 140K 1001M 1% /dev
/dev/dasdf1 1.3G 14M 1.2G 2% /tools
/dev/mapper/pvols-lhome
2.0G 33M 2.0G 2% /home
/dev/mapper/pvols-products
6.2G 79M 6.1G 2% /products
/dev/mapper/pvols-ltmp
1.0G 33M 992M 4% /tmp
Basically df -h will gives the output in human readable form (-h)
So I will try to explain each column
column 1 : Filesystem
It basically tells how many disk drives are connected and available to the user.In the above case there are 6 drives connected. and they mapped to different folders. Ex : /dev/mapper/pvols-lhome is mounted to directory /home
Column 2 : Size
This basically tells how much capacity the disk is having. Say /dev/mapper/pvols-lhome is mounted to directory /home is of 2 GB capacity
Column 3 : Used
Simple it tells how much is used from the available
Column 4 : Avail
It tells how much is free presently, which is available space
Column 5: Use%
Used disk space in terms of %
Column 6 : Mounted on
This the directory on which the disk is mounted and through which we can use the space available.
we can use df -k Which gives the output in KB format.
Go to any of ur desired location and run the command "df -h ." or "df -k ."
tvt2086:/opt/DCD_Installers # df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/dasda1 4.2G 3.9G 308M 93% /
So it tells the disk details from which current directory is taking space.
"du -sh ." tell the space that was being occupied by current directory.
tvt2086:/opt/DCD_Installers # du -sh .
472M .
In the above example the directory named "DCD_Installers" is occupying around 472 MB on the disk space.

adduser : Command to create a user in linuc
-u : Set the value of user id to 0 which is generally root user id.
-o : Set the value of user id to 0 which is generally root user id.
-g : Set the initial group number to to 0 generally root user group
-G : Supplementary groups 0=root, 1=bin, 2= daemon, 3 = sys, 4= adm, 6=disk, 10 = wheel
-M : User home directory will not be created

Displaying Remote Clients
Displaying remote X clients with Cygwin/X is nearly identical to displaying remote X clients with any other X Server. You may use the secure ssh method, or the unsecure telnet method (not recommended).
Secure ssh
On your Windows machine:
1.Make sure you have the openssh package installed.
2.Launch Cygwin/X
3.Run the following in an X terminal:
Username@CygwinHost ~
$ ssh -Y -l username remote_hostname_or_ip_address
4.Enter your password when prompted by ssh.
5.Your ssh session should now show you a shell prompt for your remote machine.
6.You can now launch remote X clients in your ssh session, for example, xterm& will launch an xterm running on your remote host that will display on your Cygwin/X screen.
7.Launch other remote clients in the same manner. I recommend starting the remote clients in the background, by appending & to the command name, so that you don't have to open several ssh sessions.
Unsecure Telnet
On your Windows machine:
1.Make sure you have the inetutils package installed.
2.Launch Cygwin/X
3.In an X terminal type /usr/bin/xhost remote_hostname_or_ip_address
4.In an X terminal type /usr/bin/telnet remote_hostname_or_ip_address. Use the explicit path to ensure that Cygwin's telnet is run instead of Microsoft's telnet; Microsoft's telnet will crash on startup when run from Cygwin/X.
5.Login to your remote machine via your telnet session
6.In your telnet session type, DISPLAY=windows_hostname_or_ip_address:0.0
7.In your telnet session type, export DISPLAY
8.You can now launch remote X clients in your telnet session, for example, xterm& will launch an xterm running on your remote host that will display on your Cygwin/X screen.
9.Launch other remote clients in the same manner; I recommend starting the remote clients in the background, by appending & to the command name, so that you don't have to open several telnet sessions.
Problems and Solutions :
When there is a problem in DISPLAYING GUIs at client side
Try to check the simple things mentioned below
1. Always the server should allow the X11 forwarding.
To check this confirm the below (Below example is from AIX 5.3 )
bash-3.00# cat /usr/local/etc/sshd_config | grep X11For linux based systems
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
nc184120:~ # cat /etc/ssh/sshd_config | grep X11
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
In case the above settings were freshly created please do restart the sshd service like below
bash-3.00# stopsrc -s sshd;startsrc -s sshd
0513-044 The sshd Subsystem was requested to stop.
0513-059 The sshd Subsystem has been started. Subsystem PID is 278682.
bash-3.00# lssrc -s sshd2. Check your client like putty like tool enabled X11 forwarding and is set to proper tunnel for the running xmanager tool
Subsystem Group PID Status
sshd tcpip 278682 active
3. If your xmanager tool is running on your client machine with port 0.0 your putty x11 forwarding should be set to localhost:0.0
How to read particular line in file in Unix.
bash-3.00$ head -n 3 a.txt | tail -1Info : === insert : nothing ON Sub-Elt Group ( ~kb ) (exists)bash-3.00$sed -n '20{;p;q;}' fileInfo : === insert : nothing ON Sub-Elt Group ( ~kb ) (exists)
Mounting a remote Directory on Solaris/Linux to a AIX machine
The best solution to know about these init levels is to understand the " man init " command output on Unix.
How to upload files from windows to Unix using FTP utility ?
e.g.:ftp> put ftp.file.htmllocal: ftp.file.html remote: ftp.file.html200 PORT command successful.150 Opening BINARY mode data connection for ftp.file.html226 Transfer completeftp> put ftp.file.html ftp.htmllocal: ftp.file.html remote: ftp.html200 PORT command successful.150 Opening BINARY mode data connection for ftp.html226 Transfer completeftp> mput */index.*mput news/index? y200 PORT command successful.150 Opening BINARY mode data connection for news/index.226 Transfer complete.442 bytes sent in 0.0835 secs (5.2 Kbytes/sec)mput news/index.html? y200 PORT command successful.150 Opening BINARY mode data connection for news/index.html.226 Transfer complete.1377 bytes sent in 0.256 secs (5.3 Kbytes/sec)mput news/index.old.shtml? nmput linux/index? y200 PORT command successful.150 Opening BINARY mode data connection for linux/index.226 Transfer complete.1192 bytes sent in 0.156 secs (7.5 Kbytes/sec)mput linux/index.html? y200 PORT command successful.150 Opening BINARY mode data connection for linux/index.html.226 Transfer complete.ftp>bye
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...
-
ఓం శ్రీ స్వామియే శరణం ఆయ్యప్ప!! Related posts : Trip to Sabarimala - Part 1 Trip to Sabarimala - Part 2 Ayappa Deeksha required things...
-
Following are some of interesting blogs I found till now ...please comment to add your blog here. Blogs in English : http://nitawriter.word...
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