Wednesday, December 23, 2009

shell command substring

The below command will print the string which is taken from the 9th index to 4 characters from 9th index.
echo | awk '{ print substr("'"$STRING"'",9,4) }'

Monday, December 21, 2009

Example Find query

The below command will list files on branch_7.0 which are not having the mentioned labels.
ct find . -version "{version(…/bracnch_7.0/LATEST) && ! lbtype(label1) && ! lbtype(label2) && ! lbtype(label3) && ! lbtype(lable4T) && ! lbtype(lable5) && ! lbtype(lable66)} " -print

Wednesday, December 9, 2009

How to create Perl Packages/Modules?

Create a file called cc.pm where the package/module name is cc. Copy the below code. I have created my own print function called myprint and going to call this function from some other script.

[murugaia@build1] ~> cat cc.pm
package cc;
sub myprint
{
my $Element = pop(@_);
print("Hai $Element\n");
};
1;

Create another script which will call package cc and its functions. Here myprint function has been called from package cc.

[murugaia@blrmimsbuild1] ~> cat cc.pl
#! /usr/bin/perl
use cc;
$print=cc::myprint("Sathiyseelan");
print("$print");

[murugaia@build1] ~>
[murugaia@build1] ~>



Friday, November 20, 2009

Clearcase substractive merge

How to do a subtractive merge in clearcase to remove changes you made in a version

1) First list the version tree.
bash # /vobs/ims_scm/test> ct lsvtree -s -all .
.@@/main
.@@/main/0
.@@/main/1
.@@/main/2
.@@/main/3
.@@/main/4
.@@/main/5
.@@/main/6
.@@/main/7
.@@/main/8
.@@/main/9
.@@/main/10

2) Remove the changes made in version 9
bash # /vobs/ims_scm/test> ct ls -d
.@@/main/10 Rule: /main/LATEST

bash # ct co -nc .

bash # /vobs/ims_scm/test> ct ls -d
.@@/main/10 Rule: /main/CHECKEDOUT

ct merge -to . -delete -version /main/9

Now version 11 of the directory will have the changes made in version 8

Wednesday, November 11, 2009

Some vital ClearCase triggers

1) comment trigger: Users must enter a comment for clearcase operations (co, ci , mkxtype... etc).
2) Post undo checkout trigger: If it is leaving 0 th version in a branch, remove the branch.
3) mkxtype trigger: All types should be created only by vob owner and root.
4) rmelem trigger: Other than vob owner and root no one should have access to remove elements.
5) rmver trigger: Other than vob owner and root no one should have access to remove versions.
6) rmname trigger: Other than vob owner and root no one should have access to remove elements from directory versions.

how to find out files to be merged between two views?

To see the difference of version selected by two clearcase views and find the files to be merged run the below command.
Cleartool setview to_version_view
cleartool findmerge PATH -ftag from_version_view -print

This command will prompt a warning message when directories are found. So need to run the following command to find out the directory list.
cleartool findmerge PATH -d -ftag from_version_view -merge -cqe

if you need only the directory list undo the check out of the current directory after collecting the list.

Monday, November 2, 2009

Difference between replicas?

1) Permission of elements. (using -npreserve when importing the replica)
2) Disk configurations and Pool's storage assignments.
3) Site wide implemented triggers.

Saturday, October 31, 2009

Quick examples of multisite commands....

1) How to manually send a file to different site.
/usr/atria/etc/utils/mkorder -data filename -copy -fship hostname_of_siteB

2) How to manually export a packet to different site?
Manually generate the packet to be send to siteB
/usr/atria/bin/multitool sync -export -ship replicaname_of_siteB

find out the packet name generated in the above command and execute the mkorder command to send the packet to the other site.
/usr/atria/etc/mkorder -data packetname -copy -fship hostname_of_siteB

3) How to import a packet manually?
Run the lspacket command to find out the packet name.
/usr/atria/bin/multitool lspacket

Run the below command to import the packet.
usr/atria/bin/multitool sync -import packetname_tobe_imported

4) How to resolve the multitool error "multitool syncreplica –import packet-pathnameSync. packet packet-pathname
was not applied to VOB ...  - packet depends on changes not yet received Packet requires changes up to 872; VOB has only 756 from replica: sanfran_hub Packet requires changes up to 605; VOB has only 500 from replica: bangalore
It means some packets have been lost and import command is not able to process the packets in the incoming bay sequentially.

We need to run chepoch command to correct the issue.
How to change the epoch numbers where there is no direct connection between two sites.
multitool lsepoch replica:replica_name_towhich_epoch_needs_tobechanged | grep -v deleted
find out the epoch row in which site you are going to change the epoch

test_default [adsita@hosta] /vobs/test> multitool lsepoch replica:"b_test_replica"
| grep -v deleted
For VOB replica "/vobs/test":
Oplog IDs for row "b_test_replica" (@ hostb):
oid:03a058ca.965d11de.934d.00:01:83:65:2d:2b=553153 (a_test_replica)
oid:6d2dc916.cb5311dd.8f84.00:01:83:0a:e8:e3=40023 (b_test_replica)
oid:24e16ab1.b8c711d5.aa4c.00:01:80:f0:6a:19=572102 (c_test_replica)
test_default [adsita@hosta] /vobs/test>

In the above example we are going to change the epoch of b_test_replica replica in site b from site a.

Loging to site b and find out its own state.
mt lsepoch replica:"b_test_replica" | grep -v deleted
test_default [adsitb@hostb] /vobs/test> mt lsepoch replica:"b_test_replica"
| grep -v deleted
For VOB replica "/vobs/test":
Oplog IDs for row "b_test_replica" (@ hostb):
oid:03a058ca.965d11de.934d.00:01:83:65:2d:2b=553150 (a_test_replica)
oid:6d2dc916.cb5311dd.8f84.00:01:83:0a:e8:e3=4002 (b_test_replica)
oid:24e16ab1.b8c711d5.aa4c.00:01:80:f0:6a:19=572001 (c_test_replica)
test_default [adsita@hosta] /vobs/test>

Login back to host a from site a and execute the below command.
multitool chepoch b_test_replica a_test_replica=4002 b_test_replica=553150 c_test_replica=572001
mt sync -export -ship b_test

login to site b and run the below command to find out the packet name.
mt lspacket

Run the below command to import the command.
mt sync -import packet_name

Monday, October 26, 2009

Change hostname of a VOB server in multisite environment

1) Lock the VOBs except to VOB owner.
2) Stop automatic MultiSite Export, Import and Shipping Poll.
3) Manually run Shipping Poll in all sites.
4) Manually run export in all sites.
5) Manually run import in all sites.
Note: Step 3,4 and 5 are run sequentially to make sure all the sites are in sync.
6) Change the hostname in the particular site where the replica object is mastered.
multitool chreplica -c "changing domainname" -host NEW_HOSTNAME replica:REPLICA_NAME
7) Manually run shipping Poll in the same site.
8) Manually run Export in the same site.
9) Manually run import in all other sites.
10) Check whether sync has happened running the below command in all other sites.
cd VOBNAME (Select a VOBNAME which has the remote replica)
multitool lsrep -l | grep new_hostname
11) If the new hostname is reflected in all sites.
12) Start automatic MultiSite export, import and shipping Poll.

Friday, October 23, 2009

How to install and configure Hudson on solaris 10?

1) Create the user and group in solaris to run Hudson service.
groupadd hudgroup
useradd -g hudgroup -d /home/hudadm -m hudadm
Note: hudadm is the username and hudgroup is the group name which will run hudson process.

2) set JAVA_HOME env variable
export JAVA_HOME=/usr/j2se/bin

3) copy the below file hudson.xml to /var/svc/manifest/application. We are going to run hudson as part of solaris SMF. We are going to define it as an application in SMF.







eout_seconds="0"/>



Hudson Continuous Build Server


4) import the hudson.xml file to SMF repository.
svccfg import /var/svc/manifest/application/hudson.xml

5) Start the service.
svcadm enable svc:/application/hudson:default

6) Check whether service is running properly or not.
bash-3.00# svcs -l svc:/application/hudson:default
fmri svc:/application/hudson:default
name Hudson Continuous Build Server
enabled true
state online
next_state none
state_time Sat Oct 24 11:57:23 2009
logfile /var/svc/log/application-hudson:default.log
restarter svc:/system/svc/restarter:default
contract_id 98
dependency require_all/none svc:/milestone/multi-user-server (online)


7) If it shows online in "state" and "dependency" then hudson is running fine.

Note:
Above hudson.xml file has been written hudson listen on 8090 port. So use http://hostname:8090/ to start hudson in any browser. Use xmllint to parse the hudson.xml file in case if you need to write your own xml file and compile it.


Tuesday, October 20, 2009

How to configure Apache with openssl?

1) Download the following softwares from sunfreeware.com
db-4.2.52.NC-sol10-intel-local
expat-2.0.1-sol10-x86-local
gcc-3.4.6-sol10-x86-local
gdbm-1.8.3-sol10-intel-local
libiconv-1.11-sol10-x86-local
zlib-1.2.3-sol10-x86-local
openssl-0.9.8k-sol10-x86-local
apache-2.0.59-sol10-x86-local

2) Install the softwares. The above apache compiled with ssl support. So no need to install mod-ssl package or compile and install apache. All the packages are data stream packages. Just use the below command to install the software.
pkgadd -d

3) Once everything is installed configure apache. (sun01 is the server name)
vi /usr/local/apache2/conf/httpd.conf

Add the following lines
Listen 80
ServerName sun01:80
DocumentRoot "/usr/local/apache2/htdocs"
NameVirtualHost *:80
IfModule mod_ssl.c> Include /usr/local/apache2/conf/ssl.conf
DocumentRoot /usr/local/apache2/htdocs ServerName sun01 ErrorLog logs/sun01-error_log CustomLog logs/sun01-access_log common >

4) Edit the ssl.conf file. (vi /usr/local/apache2/conf/ssl.conf)
Listen 8443

DocumentRoot "/usr/local/apache2/htdocs" ServerName sun01:443 ErrorLog /usr/local/apache2/logs/error_log TransferLog /usr/local/apache2/logs/access_log SSLEngine on
SSLCertificateFile /usr/local/apache2/conf/server.crt SSLCertificateKeyFile /usr/local/apache2/conf/server.key

5) Now start apache with ssl. It will start successfully
/usr/local/apache2/bin/apachectl startssl

6) Check the secure connection from windows browser. (sun01 -> servername 8443 -> ssl listen port)

7) Copy hello.html file to document root directory and try to access the following link.
cp hello.html /usr/local/apache2/htdocs

https://sun01:8443/hello.html
8) The above link will display hello.html.
9) Apache has been configured with openssl.

Thursday, October 15, 2009

How to Install and configure pkg-get

1) Download to pkg-get from any one of the links.
http://www.opencsw.org/pkg-get
http://www.bolthole.com/solaris/pkg-get.html
2) Install the package using.
pkgadd -d installed_path_of_pkg-get_package
3) Export the proxy variable
export http_proxy=IP:port
or
edit the pkg-get.conf file and add the below line under the section
# if you are behind a firewall, set these as appropriate#ftp_proxy=http://your-proxy:8023#
or#http_proxy=http://your-proxy:8023#export http_proxy ftp_proxy
export http_proxy=IP:port
4) Try to install a package using pkg-get (i am trying to use mutt)
pkg-get install mutt
The above syntax can only used if you have installed pkg-get from http://www.opencsw.org/pkg-get site. If you use the other linke you have to use pkg-get -i mutt
pkg-get will install mutt with all the depended packages.

Wednesday, October 14, 2009

Solaris packaging

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> pwd
/tmp/cmbuildtest

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> ls -lrt
total 64
-rwxr-xr-x 1 murugaia bhmobile 247 Oct 14 13:00 pkginfo*
-rw-rw-r-- 1 murugaia bhmobile 0 Oct 14 13:04 depend
drwxrwxr-x 2 murugaia bhmobile 185 Oct 14 13:08 bin/
-rwxr-xr-x 1 murugaia bhmobile 326 Oct 14 13:08 prototype*
-rwxr-xr-x 1 murugaia bhmobile 809 Oct 14 13:51 checkinstall*
murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest>

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> cat pkginfo
PKG=CMBuild
ARCH=SPARC
NAME=cmbuildtest utility is installed by this package
VERSION=1.0.1
CATEGORY=application
BASEDIR=/tmp/cmbuildtest/ PATH=/opt/CMBuild/bin/cmbuildtest /opt/CMBuild/install/checkinstall /opt/CMBuild/install/depend CLASSES=none

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> cat depend

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> find bin
bin
bin/cmbuildtest

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> cat prototype
d none /opt 0755 root bin
d none /opt/CMBuild 0755 root bin
d none /opt/CMBuild/bin=bin 0755 root bin
d none /opt/CMBuild/install=install 0755 nobody bin
f none /opt/CMBuild/bin/cmbuildtest=bin/cmbuildtest 0755 root bin
i pkginfo
i checkinstall
s none /usr/bin/cmbuildtest=/opt/CMBuild/bin/cmbuildtest 0755 root bin
i depend

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> cat checkinstall
# checkinstall script for IMStest
#
# This confirms the existence of the required SUNWcsu package
# First find package has been installed.
pkginfo -q CMBuild
if [ $? -eq 0 ]; then
echo "No SUNWcsu package can be found. Please install the"
echo "package and try this installation again."
exit 3 # Stop here
else
echo "The dependent package SUNWcsu is present on the system."
fi
# Now look for the wget file before proceeding with this installation
cmbuildtest --version
if [ $? -eq 0 ]; then
echo "wget file already present in the system."
echo " Do you want to still install?(y/n)- :c"
read response
if [ $response = y ]; then
echo "Lets proceed to install."
fi
else
echo "#################### wget currently not installed. ####################"
echo "Proceeding with the package installation."
exit 0
fi
murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest>

murugaia_default [murugaia@blrmimsbuild1] /tmp/cmbuildtest> pkgmk -o -r `pwd`
## Building pkgmap from package prototype file.
## Processing pkginfo file.
WARNING: missing directory entry for
WARNING: missing directory entry for
WARNING: parameter set to "blrmimsbuild120091014135329"
## Attempting to volumize 6 entries in pkgmap.
part 1 -- 53 blocks, 22 entries
## Packaging one part.
/var/spool/pkg/CMBuild/pkgmap
/var/spool/pkg/CMBuild/pkginfo
/var/spool/pkg/CMBuild/root/opt/CMBuild/bin/cmbuildtest
/var/spool/pkg/CMBuild/install/checkinstall
/var/spool/pkg/CMBuild/install/depend
## Validating control scripts.
WARNING: script may require user interaction at line <21>.
## Packaging complete.


bash-3.00# pkgtrans . /tmp
The following packages are available:
1 CMBuild cmbuildtest utility is installed by this package
(SPARC) 1.0.1
Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:
Transferring package instance
bash-3.00# ls -lrt /tmp grep CMBuild
drwxr-xr-x 4 root root 369 Oct 14 14:04 CMBuild
bash-3.00#

Sunday, October 11, 2009

Sample IP configuration to ping guest OS from Host OS

1) Host OS: Windows XP SP 2
C:\Documents and Settings\sathi3>ipconfig
Windows IP Configuration
Ethernet adapter VMware Network Adapter VMnet8:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.0.8
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Ethernet adapter VMware Network Adapter VMnet1:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.0.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
Ethernet adapter Wireless Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Ethernet adapter Airtel:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.1.100
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
C:\Documents and Settings\sathi3>

2) Guest OS: RedHat Linux Enterprise 5
Change the Virtual Machine Network settings to "Host-only".

3) ping the guest OS IP from Host OS. It will work as follows.
C:\Documents and Settings\sathi3>ping 192.168.0.40
Pinging 192.168.0.40 with 32 bytes of data:
Reply from 192.168.0.40: bytes=32 time=3ms TTL=64Reply from 192.168.0.40: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.0.40: Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 3ms, Average = 1ms

How to install vmware tools on Redhat linux 5?

1) Start the VM with init 3.
2) Login as root
3) Click VM -> Install Vmware Tools
mount /dev/cdrom /mnt/cdrom
cd /tmp
rpm -Uhv /mnt/cdrom/VMwareTools-5.0.0-.i386.rpm
umount /dev/cdrom
vmware-config-tools.pl
exit
vmware-toolbox &

Tuesday, September 22, 2009

set ssh key gen in Putty

Download PuTTY and PuTTYgen

Open PuTTYgen Select SSH-2 RSA Click ‘Generate’ Save the Private Key Click ‘Save private key’ (you do not have enter a password) Save the private key in location easy to remember.

Copy public-key Select all text in the public key area. right-click and select copy Configure the server settings in Putty Open Putty Click Session (left column) Enter the server hostname or IP address Enter a name under ‘Saved Sessions’ Click Connection > Data (left column) Enter ‘root’ for the auto-login username Click Connection > SSH (left column)

Select ‘2' as the Preferred SSH protocol version. Click Connection > SSH > Auth (left column) Browse to the private key from step 4. Click Session (left column) Click Save Open a session with the server Open PuTTY Select the session saved earlier. Click ‘Load’ Click ‘Open’ Login Add client public key. You should still have the public-key in the clip-board from step 5. Open the authorized_keys file on the linux server

[root@server]#vi ~/.ssh/authorized_keys2 Press the ‘i’ key to insert in vi. Go to the bottom of the file and right-click on the putty screen (This should insert the public key generated with PuTTYgen) Press the ‘esc’ key to get out of insert mode in vi. Press ‘:’ to enter command mode in vi Type ‘wq’ to write and quit vi Now, you should be finished. Let’s test. Open PuTTY Select the session saved earlier. Click ‘Load’ Click ‘Open’ If you were able to login without entering your username and password you are finished!!If not, please continue to troubleshoot. Troubleshooting: If you do not have a /root/.ssh folder, we will have to create one and set the permissions:

[root@server]#mkdir ~/.ssh
[root@server]#chmod 700 ~/.ssh

If you do not have a authorized_keys2 file, we will need to create one and set the permissions:
[root@server]#vi ~/.ssh/authorized_keys2
[root@server]#chmod 644 ~/.ssh/authorized_keys2

If you get an error that the key was rejected, you need to make sure the permissions are set correctly on the .ssh directory and authorized_keys2 file.

[root@server]#chmod 700 ~/.ssh
[root@server]#chmod 644 ~/.ssh/authorized_keys2

Tuesday, September 15, 2009

ntlogon_utill.exe

ntlogon_utill.exe will clear the credentials cache of clearcase user on windows.

CCASE_BLD_NOWAIT

set CCASE_BLD_NOWAIT=1 when you need CLEARMAKE to build in a locked VOB.

Apply Clearcase Label and Mastership

Unshared label can be applied on a branch though the branch type mastership is not with the current site.

CCRC checkout

CCRC 7.0.1 does not support checkout with -master option