Wednesday, November 26, 2008

Best Wishes for First Wedding Anniversary

Marriages are made in Heaven



"Remember that a successful marriage depends on two things: finding the right person and being the right person" quote.

Do we really know the actual definition of a successful marriage? If not than lets look for it and see what conclusion we can draw. We often say that someone somewhere is made for you and the day you come across that person you feel that that he or she is the one you have been waiting for. But later we see that due to lack of understanding and mental compatibility they move apart. So how can we say that they were the perfect match since they didn't gave any effort to understand each other. So it's important you know your partner. There are people who get physically attracted and fall for each other and eventually end up getting married. But later on when they see their wavelength not matching they easily get separated without a second thought. In today's generation we see these incidents more compare to earlier generation. And this is more due to the changing social scenario. With so many things to divert your attention you really don't know what to do.

Marriage is not just coming together of two individuals. There is much more to it. To sustain a marriage it is important that there is effort from both sides than only a marriage can carry on. A successful marriage is like a good recipe whose main ingredients are love, commitment, understanding, concern and togetherness. If you can include these aspects in your married life you can find happiness in your marriage. Andre Maurois once aptly said, "A happy marriage is a long conversation which always seems too short." which is so true. When we talk about mental compatibility between husband and wife we have seen that not only incase of arrange marriage this problem exist where both of them were unknown to each other before marriage but even after many years of courtship in love marriages this problem exist because when we meet before marriage we are at our best to impress the other person. And we start accepting each other the way we like to see each other. But gradually after marriage when we slip into our natural self that time we have to accept each other as we are. And in most of the cases the real self is not what we wanted to see and then begins the contradiction with the person whom we have loved and with whom I have to spend my life. So it's important that when you love a person love him or her the way he or she is and not the way you want him or her to be. Then only you can be happy. A happy married life calls for constant commitment and concern for each other. There are few small and minute aspects, which we tend to forget in our married life, as we get busy with the daily chores. So at times it is important to indulge in those minute details of a married life, which will constantly remind each other of the love and concern being present. We can conclude by the quote of Barnett Brickner, which says it, all that "Success in marriage does not come merely through finding the right mate, but through being the right mate."

First wedding anniversary is very important. It is one of evaluation point for life. Before marriage, we were sleeping under parents wings. After marriage, even though their blessings are there, our real life journey starts. We need to do lot of compromises against our wish. But still finding real happiness among it , is the real art. By Indian tradition, a woman has more responsibility in a family so it is applicable to you. I am sure; you will fulfill all the expectations of your family.



Have a Bright and Happy Day!

Happy anniversary to you both;
Have a bright and happy day.
Your marriage sets an example;
It shines in every way.

Time passes, and your bond is strong;
It lasts through sun and storm;
You’ll always have your love
To keep each other warm.



By Joanna Fuchs

Tuesday, October 14, 2008

Who is poor ? ( Good short story )

One day, the father of a very wealthy family took his son on a trip to the country with the express purpose of showing him how poor people live.

They spent a couple of days and nights on the farm of what would be considered a very poor family.

On their return from their trip, the father asked his son, 'How was the
trip?'

'It was great, Dad.'

'Did you see how poor people live?' the father asked.

'Oh yeah,' said the son.
'So, tell me, what did you learn from the trip?' asked the father

The son answered:
I saw that we have one dog and they had four.

We have a pool that reaches to the middle of our garden and they have a creek that has no end.

We have imported lanterns in our garden and they have the stars at night.

Our patio reaches to the front yard and they have the whole horizon.

We have a small piece of land to live on and they have fields that go beyond our sight.

We have servants who serve us, but they serve others.

We buy our food, but they grow theirs.

We have walls around our property to protect us, they have friends to protect them.'

The boy's father was speechless.

Then his son added, 'Thanks Dad for showing me how poor we are.'

Isn't perspective a wonderful thing?

Makes you wonder what would happen if we all gave thanks for everything we have, instead of worrying about what we don't have.

Appreciate every single thing you have, especially your friends!

'Life is too short and friends are too few.'


(I got this story on the mail . Published here for to get benefit to other. )

Wednesday, October 8, 2008

How to do root mirroring with SVM ?

This document explains how to do root mirroring using SVM.


Setup : root disk is dev/rdsk/c0t0d0
To be mirrored on dev/rdsk/c011d0

Create sama partition on both drive


1. prtvtoc /dev/rdsk/c0t0d0s2 > oldparttable

2. fmthard –s oldparttable /dev/rdsk/c0t11d0s2

Format all partion to be mirrored on. In this case

newfs /dev/rdsk/c0t11d0s0
newfs /dev/rdsk/c0t11d0s1
newfs /dev/rdsk/c0t11d0s3
newfs /dev/rdsk/c0t11d0s4
newfs /dev/rdsk/c0t11d0s5
newfs /dev/rdsk/c0t11d0s6
newfs /dev/rdsk/c0t11d0s7

Create replica databse.

metadb -a -c 3 -f c0t0d0s7 c0t11d0s7

Check meta database

bash-3.00# metadb
flags first blk block count
a u 16 8192 /dev/dsk/c0t0d0s7
a u 8208 8192 /dev/dsk/c0t0d0s7
a u 16400 8192 /dev/dsk/c0t0d0s7
a u 16 8192 /dev/dsk/c0t11d0s7
a u 8208 8192 /dev/dsk/c0t11d0s7
a u 16400 8192 /dev/dsk/c0t11d0s7


Create one way partition:


metainit -f d11 1 1 c0t0d0s0
metattach d10 -m d11
metainit d10 -m d11
metaroot d10

more /etc/vfstab

Create same for /var partition

metainit -f d21 1 1 c0t0d0s4
metainit d22 1 1 c0t11d0s4
metattach d20 -m d21

Check status

metastat -p

cp vfstab vfstab.bak
vi vfstab

more /etc/system

Check boot path

eeprom


boot-device=/pci@1f,4000/scsi@3/disk@0,0:a /pci@1f,4000/scsi@3/disk@b,0:a disk net


Note down boot slice path as follows:

bash-3.00# ls -al /dev/dsk/c0t0d0s0

lrwxrwxrwx 1 root root 41 Sep 15 00:26 /dev/dsk/c0t0d0s0 -> ../../devices/pci@1f,4000/scsi@3/sd@0,0:a

bash-3.00# ls -al /dev/dsk/c0t11d0s0

lrwxrwxrwx 1 root root 41 Sep 15 00:26 /dev/dsk/c0t11d0s0 -> ../../devices/pci@1f,4000/scsi@3/sd@b,0:a

Record the string that follows the /devices directory

i.e /pci@1f,4000/scsi@3/sd@b,0:a

ok> nvalias backup_root /pci@1f,4000/scsi@3/disk@b,0

ok> setenv boot-device disk backup-root net


/pci@1f,4000/scsi@3/sd@b,0:a


nvunalias backup_root /pci@1f,4000/scsi@3/sd@b,0:a ===> This is not working even though it is per SUn DOcument. ....

ok devalias
backup_root /pci@1f,4000/scsi@3/sd@b,0:a
disk5 /pci@1f,4000/scsi@3/disk@c,0
disk4 /pci@1f,4000/scsi@3/disk@b,0
disk3 /pci@1f,4000/scsi@3/disk@a,0
disk2 /pci@1f,4000/scsi@3/disk@9,0
disk1 /pci@1f,4000/scsi@3/disk@8,0
disk0 /pci@1f,4000/scsi@3/disk@0,0
disk /pci@1f,4000/scsi@3/disk@0,0
scsi /pci@1f,4000/scsi@3
cdrom /pci@1f,4000/scsi@3/disk@6,0:f
tape /pci@1f,4000/scsi@3/tape@4,0
pcia /pci@1f,2000
pcib /pci@1f,4000
pci0 /pci@1f,4000
flash /pci@1f,4000/ebus@1/flashprom@10,0
nvram /pci@1f,4000/ebus@1/eeprom@14,0
parallel /pci@1f,4000/ebus@1/ecpp@14,3043bc
net /pci@1f,4000/network@1,1
ebus /pci@1f,4000/ebus@1
i2c /pci@1f,4000/ebus@1/SUNW,envctrltwo
floppy /pci@1f,4000/ebus@1/fdthree
tty /pci@1f,4000/ebus@1/se@14,400000


ok> boot disk4


And this works for me. Hope you will make this working.

Monday, October 6, 2008

Mastani


Mastani was one of the most beautiful women in the history of India. It is said that Mastani was the daughter of the heroic king Maharaha Chhatrasal of Bundelkhand , through his Muslim mistress. Rana Chhatrasal was an exceptional prince in Indian history who took inspiration from Chhatrapati Shivaji of establishing independent kingdoms. Through 1727 and 1728, Mohammad Khan Bangash the Mughal, with an army of Afghans invaded Chattrasal’s kingdom, took Jaitpur and imprisoned him and his family within the Mughal camp. The eighty year old Chattrasal sent a distress message to Bajirao , who was on a military campaign in the vicinity, about his plight, in a poetic languange drawing a parallel with Gajendra Moksha Akhyan, a from Hindu mythology. Bajirao was the Peshwa of the Maratha kingdom. Bajirao and his mighty Maratha army helped Chhatrasal and his Bundela Rajput forces to retake Jaitpur. The old Bundela king re-entered his capital in full state, amidst the welcoming cheers of the citizens and the boom of the victorious Maratha cannons. In gratitude and as a token of his deep affection for Bajirao, whom he treated like a son-in-law, Chattrasal gave his young and beautiful daughter Mastani along with a third of his kingdom, including Jhansi, Sagar and Kalpi to Bajirao in May 1729. Chhatrasal's sons treated Bajirao as a blood-brother and later fought alongside him in many of his future campaigns. Bajirao was all of 31 years old. Mastani was the love of the young Peshwa's life and stayed devotedly by his side until his death. She resided with him at his Shaniwar Wada at Pune and rode stirrup to stirrup with him on his numerous military campaigns. Historical texts mention "People would gather on the road to see their brave king Bajirao and his beautiful mistress, Mastani." Mastani probably inspired the Peshwa Bajirao to succeed brilliantly, putting up one of the greatest contributions in building the Maratha Empire in North India and gaining total control over Mughals. She was his inspiration in battle, she bore him a valiant son and when Bajirao died, she fearlessly chose to perish in the flames of his funeral pyre. Their son, named Shamsher Bahadur , fought bravely in the Third Battle of Panipat in 1761 against Ahmed Shah Abdali , and died of serious wounds in Bharatpur after the Maratha forces lost the battle. The daughter of a Rajput father, Mastani was a skilled horse-rider, and accompanied Bajirao on all his campaigns. This often meant riding hundreds of miles over rugged country, living in camps under canvas and sharing his rough fare. She was said to be as good as any soldier in horsemanship, spear throwing and swordplay. She also had a talent for dancing and singing and Bajirao was infatuated with her. On one occasion the Peshwa went so far as to forget protocol and took her with him to Satara , when he went to pay his respects to his Shahu . This apparently drew an indignant reprimand from the Maratha monarch. The Brahmins of Pune, who had a strong influence on the Hindu rulers, could never accept Mastani as Bajirao's wife. She became the center point in Pune politics when Bajirao openly declared Mastani as his wife and their son a Brahmin. The couple faced severe resistance from Bajirao's mother, Radhabai, his wife Kashibai, his beloved brother Chimnaji Appa and the entire Brahmin community. The brahmins refused to carry out the sacred Upanayanam of Shamsher Bahadur. Later Bajirao had to take Mastani out of Shaniwar Wada. He built a separate residence for her at Kothrud, which was quite away from Kasbe Pune in those days. Separation was unfortunately inevitable. Bajirao never really recovered from this setback, and finally died of a flash fever in an army camp at Khargon, near Indore close to the banks of the Narmada , pining for Mastani. Bajirao's wife Kashibai, his brother Chimnaji and his son Balaji, came to Khargon and with them came Mastani. Bajirao's mortal remains were consigned to flames on 28th April 1740, at Raverkhed on the Narmada. At the cremation ceremony, Mastani suddenly broke through the crowd and walked into the flames. Before the stunned family could react or prevent her, the beautiful Mastani was gone. Had Bajirao's family supported the great warrior and the orthodox Brahmins accepted Mastani as a wife of Bajirao, Indian history may have gone differently. The stories of Bajirao-Mastani are amongst the few love stories in the world, between bravery and beauty.

Mastani was staying at Pabal , 70 km from Pune and had samadhi there.

Wednesday, September 24, 2008

Use of /etc/mail/aliases

We will see how to use /etc/mail/aliases efefctively ?

First find domainname of the server.

# domainname
xyz.com

Now in this case domainname of the server is xyz.com.

1. Forwarding mail to mail account rather than user. Add following lines in /etc/mail/aliases

user1: user.surname@domainname.com

Now you can send mail to user1@xyz.com and mail will distributed to user.surname@domainname.com

2. If no users are in To: field then ignore it. Add following lines in /etc/mail/aliases

undisclosed-recipients: /dev/null

3. Add following lines in /etc/mail/aliases for support

support: support@domainname.com

4. Forwarding mails to group of people

4.1 Create group called wishlist and add in /etc/mail/aliases

wishlist: :include:/admin/etc/wishlist.mail

4.2 Create file whose content looks like

# more /admin/etc/wishlist.mail

user1@domainname.com
user2@domainname.com
user3@domainname.com

Now you can send mail to wishlist@xyz.com and mail will distributed to user1@domainname.com, user2@domainname.com ,user3@domainname.com

Now you can send mails and you will receive it on new mail id. If you use effectviely your administration and support will much easier.

Script for Oracle export backup

Lot of time we need to have export backup of Oracle. Follwoing script will help to take export backup. You need to just change variable of your environment.I assumed that username password id system/manager

----------------------------------------------------------------------------------
#!/bin/sh

# Name : Oracle Export Backup
# Writer : Mahendra Rajgude
# Date : 23 Oct 2007
# Version : 0.1
# Pupose : This script is written to take oracle export backup


# Exporting environmental variable. This will specific to server.

HOSTNAME=`hostname`
ORACLE_SID=ngs
ORAWEB_ADMIN=/u01/app/oracle/admin
ORAWEB_BASE=/u01/app/oracle
ORAWEB_HOME=/u01/app/oracle/products/9.2.0
ORACLE_BASE=/u01/app/oracle
ORACLE_TERM=vt100
ORACLE_HOME=/u01/app/oracle/products/9.2.0
ORACLE_PATH=/u01/app/oracle/products/9.2.0/rdbms/admin:/u01/app/oracle/products/9.2.0/sqlplus/admin:/u01/app/oracle/common/sql
BACKUP_DIR=/oraclebackup

export ORACLE_SID ORAWEB_ADMIN ORAWEB_BASE ORAWEB_HOME ORACLE_BASE ORACLE_TERM ORACLE_HOME ORACLE_PATH BACKUP_DIR HOSTNAME

# Export DATE format to add extention to backup file.

DATE=`date '+%d'`

#echo Logfile{$DATE}

# Remove any previous backup file

rm ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}.gz

# Actual backup starts here

${ORACLE_HOME}/bin/exp system/manager full=y file=${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE} statistics=none log=${BACKUP_DIR}/${HOSTNAME}_full.log.${DATE} buffer=2048000 compress=y consistent=y


# Compression done here to reduce the size of backup


/usr/bin/gzip ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}

# Removing uncompressed file..

rm ${BACKUP_DIR}/${HOSTNAME}_full.dmp.${DATE}

#####################################################################################

# Change History

# V 1.0 Dated 23 Oct 2007 checked working fine.

Monday, September 22, 2008

Good quotes about Heart



















If GOD wants to speak to you, he will speak to through your heart. Heart then tries to tell you. You should listen to your heart if wants GOD's message for you. Mahendra Rajgude



A memory is a photograph taken by the heart
to make a special moment last forever....Unknown.

Let your heart guide you. It whispers,
so listen closely....Land Before Time.

You may hold my hand for a while,
but you hold my heart forever....Unknown.

As the ocean is never full of water,
so is the heart never full of love....Unknown.

What the heart gives away is never gone...
It is kept in the hearts of others....Robin St. John.

Love is blind only to the eyes.
The heart sees everything clearly....Unknown.

A person's actions depict the heart,
not the words they say....Brian Lee.

To get a woman's heart a man must first use his own....Unknown.

Sometimes we make love with our eyes. Sometimes we
love with our hands...Sometimes with our bodies.
Always we make love with our hearts....Unknown.

It is not the size of a man but the size of
his heart that matters....Evander Holyfield.

Follow your heart, but be quiet for a while
first. Ask questions, then feel the answer.
Learn to trust your heart....Unknown.

Precious gifts of friendship...knowing the heart of
another, sharing one's heart with another....Unknown
.

Never close your lips to those whom
you have opened your heart....Unknown.

It is only with the heart that one
can see rightly; what is essential is
invisible to the eye....Antoine De Saint-Exupery.

For it was not into my ear you whispered
but into my heart, it was not my lips
you kissed, but my soul....Judy Garland.

The best and most beautiful things in this
world cannot be seen or even heard, but must
be felt with the heart....Helen Keller.


A friend is one to whom one can pour out all the
contents of one's heart, chaff and grain together,
knowing that the gentlest of hands will take and
sift it, keeping what is worth keeping, and, with the
breath of kindness, blow the rest away....Arabian Proverb.

If you find it in your heart to care for somebody
else, you will have succeeded....Maya Angelou.

t is the heart that makes a man rich.
He is rich according to what he is,
not according to what he has....Henry Ward Beecher.

Great is the human who has not lost his childlike heart....Mencius.

Find the seed at the bottom of your heart
and bring forth a flower....Shigenori Kameoka.

Everyone should carefully observe which way
his heart draws him, and then choose that
way with all his strength....Hasidic Saying.

The heart already knows
What the mind can only dream of.
Trust your heart....Unknown.

You can admire a woman for her beauty, but you
can only respect a woman for her heart....Unknown.


Friendship is like a rainbow between two hearts....Unknown.

Follow your mind and be smart,
follow your heart and be happy....Unknown.

Wednesday, September 17, 2008

How to set password-less ssh login ?

















( The image above is from Rohit Sharma's stock photography website http://opticverse.com. Thanks to Rohit for allowing me to publish.)

It is important to note that, since the SSH protocol is a highly secure one, it does not accept just the traditonal .rhosts on the users login for accepting a remote connection without password verification.

The implementation of SSH1 and SS2 are slightly diferent, and from OpenSSH to SSH2 vary too. Since most of the Linux machines are running OpenSSH2, we will describe here how to make the "trick" for avoiding a password everytime when running openssh2 on both client and server.
For detailed information about the class of key verification and encription that ssh uses, see the ssh and related man pages or online documentation at http://www.openssh.com/manual.html

The basic idea is, however, that in the cryptosystem that ssh uses (RSA or/and DSA) the encription and decription are done using diferent keys
Basically, what the user (client) needs is to generate a public/private key pair. The server will know the public key, but only the client will know the private key.
When the client connects to the server, it tells its own public key. If this key is allowed (if it is between the know public keys list on the server), the server will send a randomic number to the client. This encripted number can only be decripted if the appropiate decription key is used, and this decription key is the client's private one. The client then uses then its own private key and decript the number. If this is done correctly, the server will grant the acces with no more questions. As you can see the system is safe, because the client never tells anybody about its private key; and this key cannot be inferred using the public one.

What must be done, then , is to generate a public/private key pair, and copy the public part into the appropiate place on the server side.
For doing this, on the user's home directory, on the client machine, type

local> ssh-keygen -t dsa -f .ssh/id_dsa

-t tells the type of encription
-f tells where to store the public/private key pairs. In this case, the .ssh directory on home is being used

A password will be asked; leave this part blank, just pressing
Now, go the .ssh directory, and you will find two new files: id_dsa and id_dsa.pub. The last one is the public part. Now, copy the public key to the server machine

local> cd .ssh
local> scp id_dsa.pub user@remote:~/.ssh/id_dsa.pub

Of course, this time you will need to enter the password.
Now, login into the server machine and go to the .ssh directory on the server side

local> ssh user@remote
remote> cd .ssh

Now, add the client's public key to the know public keys on the server

remote> cat id_dsa.pub >> authorized_keys2
remote> chmod 640 authorized_keys2
remote> rm id_dsa.pub
remote> exit

and that's all.

Next time you log into the remote server, no password will be asked.

Note that this sytem will work while none of the machines change its IP address and for the specific user, so it is still safe.

-------------------------------------------------------------------------------------

sala:~$ ssh-keygen -t dsa -f .ssh/id_dsa
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .ssh/id_dsa.
Your public key has been saved in .ssh/id_dsa.pub.
The key fingerprint is:
26:10:4b:b5:ae:c0:89:5f:d5:d1:ce:e9:5c:49:a3:63 rajgudm@sala
sala:~$ cd .ssh
sala:~/.ssh$ ls
id_dsa id_dsa.pub known_hosts


nandi:~/.ssh$ cat id_dsa.pub >> authorized_keys2
nandi:~/.ssh$ chmod 640 authorized_keys2
nandi:~/.ssh$ rm id_dsa.pub
nandi:~/.ssh$ exit
logout
Connection to nandi closed.
sala:~/.ssh$ hostname
sala

And just check if it is working ... It should work ...

sala:~/.ssh$ ssh nandi

Otherwise now find the reason for not working. Nothing fully readymade in this world. :)

Sunday, September 14, 2008

How to recover root password of Sun Server ?

















Step−by−Step Procedure



If the system is not halted, then halt the system by pressing Stop−A. This will bring you to the OK prompt.

Place the installation CD−ROM in the CD−ROM drive. Boot the system to single user mode using the CD−ROM drive.

Type : boot cdrom −s ======> If you are booting from -ROM
Type : boot net -s ======> If you are booting from Network Jump Start Server.

( For u need to server configure. That procedure is not included here)


It may take awhile, but you will automatically be logged in as root in single user mode running the OS from the CD−ROM.

1. If you had to force halt the system, by pressing Stop−A for instance, then the partitions on the hard disk will not be marked as being shutdown cleanly. If this happens, run fsck on the root partition. It is used to check and repair the file system. In this case it won't ask for the root password as it is in single
user mode. Type: fsck −y /dev/dsk/c0t3d0s0

2. Now c0t3d0s0 is just the root partition in this example. Verify your boot disk.

4. Remove root's password using your editor and edit /a/etc/shadow. Find root's entry in the file and make the second field null. Colons are the field delimeters. So your entry, after changes, should look something like:

root::10565::::::

Various fields will be used if certain parameters have been set for the OS.

5. Boot to single user mode using the hard disk.

Type: reboot −− −s

Note: That is, reboot space hyphen hyphen space hyphen s.

6.You can log in as root without a password and set root's password using the passwd command.

7. Exit single user mode and let the system continue booting to multi−user mode.

Wednesday, September 10, 2008

How extend soft partition?

Objective :

1. To extend soft partition by keeping data intact.
2. To extend meta partition by keeping data intact

Audience :
Audience of the document should be well aware of Solaris commands. They should have proper knowledge of SVM concept and commands. I am assuming that the users are aware of impact of the commands and for safer side , I recommends to take backup before starting exercise.

Setup :

1. Slice used to meta database c0t0d0s7 and size is 100 Mb
2. c0t0d0s7 is 2.7 GB
3. c0t9d0s0 10 Gb

Steps :

1. Create database

bash-3.00# metadb -f -a -c 3 c0t0d0s7
bash-3.00# metadb
flags first blk block count
a u 16 8192 /dev/dsk/c0t0d0s7
a u 8208 8192 /dev/dsk/c0t0d0s7
a u 16400 8192 /dev/dsk/c0t0d0s7

2. Create meta device d10

bash-3.00# metainit d10 1 1 c0t0d0s4

d10: Concat/Stripe is setup
bash-3.00# metastat
d10: Concat/Stripe
Size: 3986352 blocks (1.9 GB)
Stripe 0:
Device Start Block Dbase Reloc
c0t0d0s4 0 No Yes

Device Relocation Information:
Device Reloc Device ID
c0t0d0 Yes id1,sd@SFUJITSU_MAG3182L_SUN18G_01585615____

3. Create new soft partition

bash-3.00# metainit d31 -p d10 1g
d31: Soft Partition is setup
bash-3.00# metastat
d31: Soft Partition
Device: d10
State: Okay
Size: 2097152 blocks (1.0 GB)
Extent Start Block Block count
0 32 2097152

d10: Concat/Stripe
Size: 3986352 blocks (1.9 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0t0d0s4 0 No Okay Yes

Device Relocation Information:
Device Reloc Device ID
c0t0d0 Yes id1,sd@SFUJITSU_MAG3182L_SUN18G_01585615____

4. Format the newly created soft partition and mount it

# newfs /dev/md/dsk/d31

newfs: construct a new file system /dev/md/rdsk/d31: (y/n)? yes
Warning: 4400 sector(s) in last cylinder unallocated
/dev/md/rdsk/d31: 2097152 sectors in 446 cylinders of 19 tracks, 248 secto
rs
1024.0MB in 28 cyl groups (16 c/g, 36.81MB/g, 17664 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 75680, 151328, 226976, 302624, 378272, 453920, 529568, 605216, 680864,
1361696, 1437344, 1512992, 1588640, 1664288, 1739936, 1815584, 1891232,
1966880, 2042528

bash-3.00# mkdir /test1
bash-3.00# mount /dev/md/dsk/d32 /test1

bash-3.00# df –h /test
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d31 963M 1.0M 904M 1% /test

5. Addition of more space in d10

bash-3.00# metattach d10 c0t9d0s0
d10: component is attached

bash-3.00# metastat
d32: Soft Partition
Device: d10
State: Okay
Size: 1024000 blocks (500 MB)
Extent Start Block Block count
0 2097216 1024000

d10: Concat/Stripe
Size: 39533680 blocks (18 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0t0d0s4 0 No Okay Yes
Stripe 1:
Device Start Block Dbase State Reloc Hot Spare
c0t9d0s0 5080 No Okay Yes

d31: Soft Partition
Device: d10
State: Okay
Size: 2097152 blocks (1.0 GB)
Extent Start Block Block count
0 32 2097152

Device Relocation Information:
Device Reloc Device ID
c0t0d0 Yes id1,sd@SFUJITSU_MAG3182L_SUN18G_01585615____
c0t9d0 Yes id1,sd@x002037fffebcf385


6. Copy some data make partition full so that we can test it late for extension.

bash-3.00# df -h /test
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d31 963M 960M 0K 100% /test


7. Add 2 Gb space in partition d31

bash-3.00# metattach d31 2g
d31: Soft Partition has been grown

bash-3.00# df -h /test
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d31 963M 960M 0K 100% /test

( Please note partition size is still not grown.)

8. Now final step that will make partition grow without destroying data.

bash-3.00# growfs -M /test /dev/md/rdsk/d31
Warning: 3776 sector(s) in last cylinder unallocated
/dev/md/rdsk/d31: 6291456 sectors in 1336 cylinders of 19 tracks, 248 sectors
3072.0MB in 84 cyl groups (16 c/g, 36.81MB/g, 17664 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 75680, 151328, 226976, 302624, 378272, 453920, 529568, 605216, 680864,
5581600, 5657248, 5732896, 5808544, 5884192, 5959840, 6035488, 6111136,
6186784, 6262432

bash-3.00# df -h
Filesystem size used avail capacity Mounted on

/dev/md/dsk/d31 2.8G 962M 1.8G 34% /test

That’s it.

Wednesday, September 3, 2008

Animal Sketches

On one fine Saturday while in UK around Aug 2008 , I was very bored. I took pen ,paper and started drawing animal faces. In the first attempt , I think I made it. It is definately not best but surely not bad also.



Life and relationship


“Life is all about hit & misses".


The same is true for relationships. Some time it works out, Sometimes not.
It hurts & hurts terribly when expectations are belied, when emotions are trampled & you feel ignored & cheated.
The only way to make a relationship work is determination to ensure it works. However Fear of getting hurt can put you off the relationship.
I need a relationship in which I don’t have to keep explaining myself. I'm searching for that relationship in which I can enjoy freedom of trust.
I need a relationship in which I won’t be held up against myself. I have my strengths & I have my weaknesses.
The search is for that one relationship in which my lesser side wont be provoked & instigated constantly.
I want someone who will always relate to my better side.
I want a relationship in which my positives will always be brought to the fore.
I need a relationship in which my today is not viewed with the mistakes I made yesterday.
I need a relationship where tomorrow’s misery isn’t already confirmed, for the mistake i've made today.
As a human I'm bound to err occasionally. I want someone who won’t maintain a database of my mistakes.
The search is for that one relationship where yesterday's fight doesn't intrude into today's intimacy, where yesterday's argument doesn't halt today's communication.
I need a relationship in which it isn't me who has to take initiative all the time. I need a relationship where I can afford to be transparent.
I need a relationship in which I don’t have to alter my likes & dislikes in order to gain & retain the relationship. I need a relationship in which my self image is not scratched.I need a relationship in which I'm not asked to be anyone other that who I am.. what I am. I need a relationship in which I feel completely myself.
I need that one relationship in which I feel as though I am once again in my mother's womb. A relationship in which my heart always feels... just born.

If you already have one such relationship.. please go down on your knees in gratitude, for there cannot be greater gift from life. Such a relationship is life's greatest gift.

(This article is not written by me. I like it so I posted here. Thanks to genius who written this.)

Monday, August 25, 2008

Regret ( Heart touching short story)

I entered a small room of ten by ten in the middle of the slum. An old man was sitting there. The moment he saw me, his eyes sparkled and a smile spread across his face. He stood up and taking my hand in his, said “Please welcome, my child ...“. He started asking eagerly about how I am doing and all about me.



After I became a computer engineer, I went to meet him after quite a long time. He was very old by now. Few years ago, he had taken early retirement and thought about enjoying life. Unfortunately, he got sick and spent most of his money on medical expenses. As his son was not earning anything, he was forced to spend his remaining life in a slum.



He had spent his life very lavishly while he was young. After seeing him, I bowed and touched his feet for blessings. He was so happy while blessing me.



My mind went back fifteen years when I was in first year of college. At that time, my college decided to start graduation in Electronics announcing a fee of 1500/- rupees. As my father was very poor; he could not afford even this fee. I was very sad and as a final resort; had approached the same old man for help. Even he was in a financial crisis at that time; but he helped me because of which I got admission to Electronics. Years passed, I got nice marks and life moved further and finally got good job as a computer engineer.



He was utmost happy to see me. His expressions were enough to tell what was going inside his heart. He was proud of his investment of Rs 1500. After initial chatting, I got some clue that he is in a financial problem. I tried to offer him some money but he was not ready to accept. After lot of efforts, he accepted the small amount. He said that he doesn’t need money and he will manage somehow.



After half an hour, I bade him fare well. He suggested that I come again to meet him. I was so happy that I could help the person who had helped me.



A month passed. One day, a relative of the old man called on my mobile and informed me about the bad news. The old man had committed suicide by throwing himself in front of running train because he didn’t have money to purchase medicine.



I was speechless. My help to the old man was not enough. His money had turned my life but my money could not

Friday, August 22, 2008

Simple start with ZFS

Here is very simple steps to start with zfs


1. Create ZFS filesystem wih single disk.

bash-3.00# zpool create tank c0t9d0s0
invalid vdev specification
use '-f' to override the following errors:
/dev/dsk/c0t9d0s0 contains a ufs filesystem.
/dev/dsk/c0t9d0s0 overlaps with /dev/dsk/c0t9d0s3

If you face above error just add -f option as following.

bash-3.00# zpool create -f tank c0t9d0s0

2. How see zfs details?

Following command shows details of pool fs we just created.

bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
tank 16.9G 83.5K 16.9G 0% ONLINE

3. Now we need to create partitions in it. Let's create 5 Gb parttion.

bash-3.00# zfs set quota=5G tank/vol1
bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
tank 104K 16.6G 25.5K /tank
tank/vol1 24.5K 5.00G 24.5K /tank/vol1

4. How can extend it ?

Very simple. See fire following command.

bash-3.00# zfs set quota=10G tank/vol1

5. Again do zfs list see what is happended.

bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
tank 104K 16.6G 25.5K /tank
tank/vol1 24.5K 10.0G 24.5K /tank/vol1


bash-3.00# df -h
Filesystem size used avail capacity Mounted on

tank 17G 25K 17G 1% /tank
tank/vol1 13G 24K 13G 1% /tank/vol1

bash-3.00#

6. How to see statistics ?

bash-3.00# zpool iostat tank

capacity operations bandwidth
pool used avail read write read write
---------- ----- ----- ----- ----- ----- -----
tank 108K 16.9G 0 0 0 10

7. How to mount zfs partition at your desired mountpoint?

#
# zfs set mountpoint=/export/zfs tank/vol1

Effect will be shown as following if df -h command

tank/vol1 10G 24K 10G 1% /export/zfs


8. Finding zfs status


bash-3.00# zpool status
pool: tank
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
c0t9d0s0 ONLINE 0 0 0

errors: No known data errors

=====================================================================================

For further study visit here:

1. http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide
2. http://docs.sun.com/app/docs/doc/819-5461

Friday, August 8, 2008

How to restrict sudo -s or su ?

It is very difficult to restrict sudo -s or su -. After struggling a lot , I found way to restrict it.

I am assuming that you have sudo implementation knowledge.


The Impact of sudo on Unix System Security
1) `sudo` improves on `su` in several ways:
2) `sudo` allows you to give privileged access to only some commands, instead of all commands.
3) `sudo` allows you to log all commands (and their arguments) executed as the privileged user.
4) `sudo` does not require the administrator to share the root password.
5) `sudo` allows you to limit the users who can use it by editing the sudoers file.
6) `sudo` times out after 5 minutes (by default).

Tips:

1. How to restrict sudo -s
If username is user1 then add following configuration in sudoers file

user1 ALL=(root) NOPASSWD:/usr/sbin/a*,(root)NOPASSWD:/usr/sbin/[c-r]*,(root) NOPASSWD:/usr/sbin/[t-z]*,(root) NOPASSWD:/usr/bin/a*,(root) NOPASSWD:/usr/bin/[c-r]*,(root) NOPASSWD:/usr/bin/[tuwxyz]*,(root) NOPASSWD:/bin/a*,(root) NOPASSWD:/bin/[c-r]*,(root) NOPASSWD:/bin/[tuvwxyz]*

Above file

1) Restrict any command in /usr/sbin , /bin and /bin/bin who alphabet starts from b,v,s ( i.e bash,vi,sudo and su etc )
2) It will not ask for password

2) How to log the usage ?

Add following line to sudoers files.

Defaults logfile=/var/adm/sudolog

Monday, July 21, 2008

How to use sed ? Practicle use of sed

1. To find and remove perticular word
sed 's/root/mahendra/g' file1.txt
2. Write the statement to remove '/' from df -k using sed df -k sed 's/\// /g'
3. sed work fine with regular expression df -k sed 's/$/EOL/' -> This will add EOL at the end of line.
4. How to find blank line
sed 's/^$/this used to be a blank line/' file1.txt grep " used t" wc -l
5. . means any character more /var/adm/messagessed 's/Jan .. ..:..:../Jan 2008/g' more
6. The '*' character means "any number of the previous character". This applies both to literal characters and to characters that are a result of using "[]" or '.'. For example, sed 's/ *$//' filename
deletes all trailing spaces from each line, while
sed 's/[ ]*$//' filename
deletes any sequence of trailing tabs and spaces. It also works when using "[^]":
sed 's/[ ][^ ]*$//' filename
deletes the last word (sequence of non-spaces) on each line.
7. It is important to know that '*' will match zero occurences. If you need to match an integer, for example,
sed 's/ [0-9]* / integer /g' filename
will turn " " into " integer ", which is not what you want. In this case, you should use
sed 's/ [0-9][0-9]* / integer /g' filename
which will demand at least one digit.
8. Removing perticuler string.
df -k sed 's/[e-o][mn]/YES/g' This will find all letters ending with m or n and any letter from e to o to their previous position.
9. sed 1d ==> delete row 1 sed 2d ==> delete row 2 sed 1,2d ==> delete row 1,2
-------------------------------------------------------------------------
FILE SPACING:
# double space a file sed G
# double space a file which already has blank lines in it. Output file # should contain no more than one blank line between lines of text. sed '/^$/d;G'
# triple space a file sed 'G;G'
# undo double-spacing (assumes even-numbered lines are always blank) sed 'n;d'
# insert a blank line above every line which matches "regex" sed '/regex/{x;p;x;}'
# insert a blank line below every line which matches "regex" sed '/regex/G'
# insert a blank line above and below every line which matches "regex" sed '/regex/{x;p;x;G;}'
NUMBERING:
# number each line of a file (simple left alignment). Using a tab (see # note on '\t' at end of file) instead of space will preserve margins. sed = filename sed 'N;s/\n/\t/'
# number each line of a file (number on left, right-aligned) sed = filename sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'
# number each line of file, but only print numbers if line is not blank sed '/./=' filename sed '/./N; s/\n/ /'
# count lines (emulates "wc -l") sed -n '$='
TEXT CONVERSION AND SUBSTITUTION:
# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format sed 's/.$//' # assumes that all lines end with CR/LF sed 's/^M$//' # in bash/tcsh, press Ctrl-V then Ctrl-M sed 's/\x0D$//' # gsed 3.02.80, but top script is easier
# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format sed "s/$/`echo -e \\\r`/" # command line under ksh sed 's/$'"/`echo \\\r`/" # command line under bash sed "s/$/`echo \\\r`/" # command line under zsh sed 's/$/\r/' # gsed 3.02.80
# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format sed "s/$//" # method 1 sed -n p # method 2
# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format # Can only be done with UnxUtils sed, version 4.0.7 or higher. # Cannot be done with other DOS versions of sed. Use "tr" instead. sed "s/\r//" infile >outfile # UnxUtils sed v4.0.7 or higher tr -d \r outfile # GNU tr version 1.22 or higher
# delete leading whitespace (spaces, tabs) from front of each line # aligns all text flush left sed 's/^[ \t]*//' # see note on '\t' at end of file
# delete trailing whitespace (spaces, tabs) from end of each line sed 's/[ \t]*$//' # see note on '\t' at end of file
# delete BOTH leading and trailing whitespace from each line sed 's/^[ \t]*//;s/[ \t]*$//'
# insert 5 blank spaces at beginning of each line (make page offset) sed 's/^/ /'
# align all text flush right on a 79-column width sed -e :a -e 's/^.\{1,78\}$/ &/;ta' # set at 78 plus 1 space
# center all text in the middle of 79-column width. In method 1, # spaces at the beginning of the line are significant, and trailing # spaces are appended at the end of the line. In method 2, spaces at # the beginning of the line are discarded in centering the line, and # no trailing spaces appear at the end of lines. sed -e :a -e 's/^.\{1,77\}$/ & /;ta' # method 1 sed -e :a -e 's/^.\{1,77\}$/ &/;ta' -e 's/\( *\)\1/\1/' # method 2
# substitute (find and replace) "foo" with "bar" on each line sed 's/foo/bar/' # replaces only 1st instance in a line sed 's/foo/bar/4' # replaces only 4th instance in a line sed 's/foo/bar/g' # replaces ALL instances in a line sed 's/\(.*\)foo\(.*foo\)/\1bar\2/' # replace the next-to-last case sed 's/\(.*\)foo/\1bar/' # replace only the last case
# substitute "foo" with "bar" ONLY for lines which contain "baz" sed '/baz/s/foo/bar/g'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz" sed '/baz/!s/foo/bar/g'
# change "scarlet" or "ruby" or "puce" to "red" sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g' # most seds gsed 's/scarlet\ruby\puce/red/g' # GNU sed only
# reverse order of lines (emulates "tac") # bug/feature in HHsed v1.5 causes blank lines to be deleted sed '1!G;h;$!d' # method 1 sed -n '1!G;h;$p' # method 2
# reverse each character on the line (emulates "rev") sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
# join pairs of lines side-by-side (like "paste") sed '$!N;s/\n/ /'
# if a line ends with a backslash, append the next line to it sed -e :a -e '/\\$/N; s/\\\n//; ta'
# if a line begins with an equal sign, append it to the previous line # and replace the "=" with a single space sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D'
# add commas to numeric strings, changing "1234567" to "1,234,567" gsed ':a;s/\B[0-9]\{3\}\>/,&/;ta' # GNU sed sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' # other seds
# add commas to numbers with decimal points and minus signs (GNU sed) gsed ':a;s/\(^\[^0-9.]\)\([0-9]\+\)\([0-9]\{3\}\)/\1\2,\3/g;ta'
# add a blank line every 5 lines (after lines 5, 10, 15, 20, etc.) gsed '0~5G' # GNU sed only sed 'n;n;n;n;G;' # other seds
SELECTIVE PRINTING OF CERTAIN LINES:
# print first 10 lines of file (emulates behavior of "head") sed 10q
# print first line of file (emulates "head -1") sed q
# print the last 10 lines of a file (emulates "tail") sed -e :a -e '$q;N;11,$D;ba'
# print the last 2 lines of a file (emulates "tail -2") sed '$!N;$!D'
# print the last line of a file (emulates "tail -1") sed '$!d' # method 1 sed -n '$p' # method 2
# print only lines which match regular expression (emulates "grep") sed -n '/regexp/p' # method 1 sed '/regexp/!d' # method 2
# print only lines which do NOT match regexp (emulates "grep -v") sed -n '/regexp/!p' # method 1, corresponds to above sed '/regexp/d' # method 2, simpler syntax
# print the line immediately before a regexp, but not the line # containing the regexp sed -n '/regexp/{g;1!p;};h'
# print the line immediately after a regexp, but not the line # containing the regexp sed -n '/regexp/{n;p;}'
# print 1 line of context before and after regexp, with line number # indicating where the regexp occurred (similar to "grep -A1 -B1") sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h
# grep for AAA and BBB and CCC (in any order) sed '/AAA/!d; /BBB/!d; /CCC/!d'
# grep for AAA and BBB and CCC (in that order) sed '/AAA.*BBB.*CCC/!d'
# grep for AAA or BBB or CCC (emulates "egrep") sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d # most seds gsed '/AAA\BBB\CCC/!d' # GNU sed only
# print paragraph if it contains AAA (blank lines separate paragraphs) # HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'
# print paragraph if it contains AAA and BBB and CCC (in any order) sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'
# print paragraph if it contains AAA or BBB or CCC sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d gsed '/./{H;$!d;};x;/AAA\BBB\CCC/b;d' # GNU sed only
# print only lines of 65 characters or longer sed -n '/^.\{65\}/p'
# print only lines of less than 65 characters sed -n '/^.\{65\}/!p' # method 1, corresponds to above sed '/^.\{65\}/d' # method 2, simpler syntax
# print section of file from regular expression to end of file sed -n '/regexp/,$p'
# print section of file based on line numbers (lines 8-12, inclusive) sed -n '8,12p' # method 1 sed '8,12!d' # method 2
# print line number 52 sed -n '52p' # method 1 sed '52!d' # method 2 sed '52q;d' # method 3, efficient on large files
# beginning at line 3, print every 7th line gsed -n '3~7p' # GNU sed only sed -n '3,${p;n;n;n;n;n;n;}' # other seds
# print section of file between two regular expressions (inclusive) sed -n '/Iowa/,/Montana/p' # case sensitive
SELECTIVE DELETION OF CERTAIN LINES:
# print all of file EXCEPT section between 2 regular expressions sed '/Iowa/,/Montana/d'
# delete duplicate, consecutive lines from a file (emulates "uniq"). # First line in a set of duplicate lines is kept, rest are deleted. sed '$!N; /^\(.*\)\n\1$/!P; D'
# delete duplicate, nonconsecutive lines from a file. Beware not to # overflow the buffer size of the hold space, or else use GNU sed. sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P'
# delete all lines except duplicate lines (emulates "uniq -d"). sed '$!N; s/^\(.*\)\n\1$/\1/; t; D'
# delete the first 10 lines of a file sed '1,10d'
# delete the last line of a file sed '$d'
# delete the last 2 lines of a file sed 'N;$!P;$!D;$d'
# delete the last 10 lines of a file sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1 sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2
# delete every 8th line gsed '0~8d' # GNU sed only sed 'n;n;n;n;n;n;n;d;' # other seds
# delete ALL blank lines from a file (same as "grep '.' ") sed '/^$/d' # method 1 sed '/./!d' # method 2
# delete all CONSECUTIVE blank lines from file except the first; also # deletes all blank lines from top and end of file (emulates "cat -s") sed '/./,/^$/!d' # method 1, allows 0 blanks at top, 1 at EOF sed '/^$/N;/\n$/D' # method 2, allows 1 blank at top, 0 at EOF
# delete all CONSECUTIVE blank lines from file except the first 2: sed '/^$/N;/\n$/N;//D'
# delete all leading blank lines at top of file sed '/./,$!d'
# delete all trailing blank lines at end of file sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' # works on all seds sed -e :a -e '/^\n*$/N;/\n$/ba' # ditto, except for gsed 3.02*
# delete the last line of each paragraph sed -n '/^$/{p;h;};/./{x;/./p;}'
SPECIAL APPLICATIONS:
# remove nroff overstrikes (char, backspace) from man pages. The 'echo' # command may need an -e switch if you use Unix System V or bash shell. sed "s/.`echo \\\b`//g" # double quotes required for Unix environment sed 's/.^H//g' # in bash/tcsh, press Ctrl-V and then Ctrl-H sed 's/.\x08//g' # hex expression for sed v1.5
# get Usenet/e-mail message header sed '/^$/q' # deletes everything after first blank line
# get Usenet/e-mail message body sed '1,/^$/d' # deletes everything up to first blank line
# get Subject header, but remove initial "Subject: " portion sed '/^Subject: */!d; s///;q'
# get return address header sed '/^Reply-To:/q; /^From:/h; /./d;g;q'
# parse out the address proper. Pulls out the e-mail address by itself # from the 1-line return address header (see preceding script) sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//'
# add a leading angle bracket and space to each line (quote a message) sed 's/^/> /'
# delete leading angle bracket & space from each line (unquote a message) sed 's/^> //'
# remove most HTML tags (accommodates multiple-line tags) sed -e :a -e 's/<[^>]*>//g;/ # extract multi-part uuencoded binaries, removing extraneous header # info, so that only the uuencoded portion remains. Files passed to # sed must be passed in the proper order. Version 1 can be entered # from the command line; version 2 can be made into an executable # Unix shell script. (Modified from a script by Rahul Dhesi.) sed '/^end/,/^begin/d' file1 file2 ... fileX uudecode # vers. 1 sed '/^end/,/^begin/d' "$@" uudecode # vers. 2
# zip up each .TXT file individually, deleting the source file and # setting the name of each .ZIP file to the basename of the .TXT file # (under DOS: the "dir /b" switch returns bare filenames in all caps). echo @echo off >zipup.bat dir /b *.txt sed "s/^\(.*\)\.TXT/pkzip -mo \1 \1.TXT/" >>zipup.bat
TYPICAL USE: Sed takes one or more editing commands and applies all ofthem, in sequence, to each line of input. After all the commands havebeen applied to the first input line, that line is output and a secondinput line is taken for processing, and the cycle repeats. Thepreceding examples assume that input comes from the standard inputdevice (i.e, the console, normally this will be piped input). One ormore filenames can be appended to the command line if the input doesnot come from stdin. Output is sent to stdout (the screen). Thus:
cat filename sed '10q' # uses piped input sed '10q' filename # same effect, avoids a useless "cat" sed '10q' filename > newfile # redirects output to disk
For additional syntax instructions, including the way to apply editingcommands from a disk file instead of the command line, consult "sed &awk, 2nd Edition," by Dale Dougherty and Arnold Robbins (O'Reilly,1997; http://www.ora.com), "UNIX Text Processing," by Dale Doughertyand Tim O'Reilly (Hayden Books, 1987) or the tutorials by Mike Arstdistributed in U-SEDIT2.ZIP (many sites). To fully exploit the powerof sed, one must understand "regular expressions." For this, see"Mastering Regular Expressions" by Jeffrey Friedl (O'Reilly, 1997).The manual ("man") pages on Unix systems may be helpful (try "mansed", "man regexp", or the subsection on regular expressions in "maned"), but man pages are notoriously difficult. They are not written toteach sed use or regexps to first-time users, but as a reference textfor those already acquainted with these tools.
QUOTING SYNTAX: The preceding examples use single quotes ('...')instead of double quotes ("...") to enclose editing commands, sincesed is typically used on a Unix platform. Single quotes prevent theUnix shell from intrepreting the dollar sign ($) and backquotes(`...`), which are expanded by the shell if they are enclosed indouble quotes. Users of the "csh" shell and derivatives will also needto quote the exclamation mark (!) with the backslash (i.e., \!) toproperly run the examples listed above, even within single quotes.Versions of sed written for DOS invariably require double quotes("...") instead of single quotes to enclose editing commands.
USE OF '\t' IN SED SCRIPTS: For clarity in documentation, we have usedthe expression '\t' to indicate a tab character (0x09) in the scripts.However, most versions of sed do not recognize the '\t' abbreviation,so when typing these scripts from the command line, you should pressthe TAB key instead. '\t' is supported as a regular expressionmetacharacter in awk, perl, and HHsed, sedmod, and GNU sed v3.02.80.
VERSIONS OF SED: Versions of sed do differ, and some slight syntaxvariation is to be expected. In particular, most do not support theuse of labels (:name) or branch instructions (b,t) within editingcommands, except at the end of those commands. We have used the syntaxwhich will be portable to most users of sed, even though the popularGNU versions of sed allow a more succinct syntax. When the reader seesa fairly long command such as this:
sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d
it is heartening to know that GNU sed will let you reduce it to:
sed '/AAA/b;/BBB/b;/CCC/b;d' # or even sed '/AAA\BBB\CCC/b;d'
In addition, remember that while many versions of sed accept a commandlike "/one/ s/RE1/RE2/", some do NOT allow "/one/! s/RE1/RE2/", whichcontains space before the 's'. Omit the space when typing the command.
OPTIMIZING FOR SPEED: If execution speed needs to be increased (due tolarge input files or slow processors or hard disks), substitution willbe executed more quickly if the "find" expression is specified beforegiving the "s/.../.../" instruction. Thus:
sed 's/foo/bar/g' filename # standard replace command sed '/foo/ s/foo/bar/g' filename # executes more quickly sed '/foo/ s//bar/g' filename # shorthand sed syntax
On line selection or deletion in which you only need to output linesfrom the first part of the file, a "quit" command (q) in the scriptwill drastically reduce processing time for large files. Thus:
sed -n '45,50p' filename # print line nos. 45-50 of a file sed -n '51q;45,50p' filename # same, but executes much faster
If you have any additional scripts to contribute or if you find errorsin this document, please send e-mail to the compiler. Indicate theversion of sed you used, the operating system it was compiled for, andthe nature of the problem. Various scripts in this file were writtenor contributed by:
Al Aab <af137@freenet.toronto.on.ca> # "seders" list moderator Edgar Allen <era@sky.net> # various Yiorgos Adamopoulos <adamo@softlab.ece.ntua.gr> Dale Dougherty <dale@songline.com> # author of "sed & awk" Carlos Duarte <cdua@algos.inesc.pt> # author of "do it with sed" Eric Pement <pemente@northpark.edu> # author of this document Ken Pizzini <ken@halcyon.com> # author of GNU sed v3.02 S.G. Ravenhall <stew.ravenhall@totalise.co.uk> # great de-html script Greg Ubben <gsu@romulus.ncsc.mil> # many contributions & much help-------------------------------------------------------------------------

The combination ".*" means any number of any character. So, sed 's/col.*lapse/collapse/g' filename
will act on any line which contains the letters "col" and then "lapse", no matter what is in between. The '*' character is greedy: it takes as many characters as it can. So, the above script would turn
a b col d e f lapse h i j k lapse m n
into a b collapse m n
instead of a b collapse h i j k lapse m n
back to the top Substitution and SavingUp to this point, we have concentrated on deleting things that we match with "[]" and '.'. That's because we had no way of saving what we matched. The "\(" and "\)" operators will save whatever is found between them. Notice that these parentheses must be preceded by a backslash, while the characters ^$[].*\ don't need a backslash to act in a non-literal fashion. The first pair of "\(\)" saves into a place called "\1", and the second pair into "\2", and so on. sed 's/^\([A-Z][A-Za-z]*\), \([A-Z][A-Za-z]*\)/\2 \1/' filename
will turn "Lastname, Firstname" into "Firstname Lastname". Notice how the comma is placed outside the first pair of "\(\)" so it doesn't get inclued in the last name. Otherwise, the result would be "Firstname Lastname,".
Sometimes you will want to apply a substitution only to lines that meet some criteria that you can't specify in the string to be replaced. You do this using something called an "address". It comes before the "s" command. You can limit the command to a range of lines:
sed '1,20s/foobar/fubar/g' filename
The line count is cumulative across files, and starts at 1.
You might want to apply a change only to lines that contain a string:
sed '/^Aug/s/Mon /Monday /g' filename
Or to lines that don't contain a string:
using sh or ksh or bash,
sed '/^Aug/!s/Mon /Monday /g' filename
using csh or tcsh,
sed '/^Aug/\!s/Mon /Monday /g' filename
You can also apply the command to all lines between (and including) a start string and a stop string: sed '/^Aug/,/^Oct/s/Mon /Monday /g' filename
Normally sed reads a line, processes it, and prints it out. If you only want to see the lines that your command acted upon, then you don't want it to print out everyting. The "-n" flag will stop sed from printing after processing. So,
sed -n 's/fubar/foobar/g' filename
will print nothing at all. You must use the 'p' flag to the 's' command to make it print out what it has processed:
sed -n 's/fubar/foobar/gp' filename
Sed from a fileIf your sed script is getting long, you can put it into a file, like so: # This file is named "sample.sed" # comments can only appear in a block at the beginning s/color/colour/g s/flavor/flavour/g s/theater/theatre/g
Then call sed with the "-f" flag: sed -f sample.sed filename
Or, you can make an executable sed script:
#!/usr/bin/sed -f # This file is named "sample2.sed" s/color/colour/g s/flavor/flavour/g s/theater/theatre/g
then give it execute permissions: chmod u+x sample2.sed
and then call it like so:
./sample2.sed filename

Sunday, July 13, 2008

In search of new life …


People had lot of happiness in their life but they don’t know when it came in their life. They only realising after loosing it.

When I read this sentence, my mind forced me to think seriously on this statement. Objective of life is to be happy. If we have lot of happiness around us and if we are aware of it, is really serious thing.

We are searching happiness in very big way. Lot of time, really don’t know whether that will make us happy. Still we are giving our precious years , days and night sand finally after getting it; we found that it was just basic need of life or does not worth what we paid for it. Where is happiness then ?

To become stable in life ,we need good home , a four wheeler and steady income for meeting our daily needs. We also want to have good education for our childern , admission in good school. We also want steady flow of money for on-going needs. Obviously it is not so easy to achieve all easily. After globalization, world become smaller. We can now daily login to server located at other end of the earth. We can talk anywhere in this world within few seconds. Techonolgy made it possible. Oppertunities are open and hence much wider choice for become happy.

Unfortunately this lighter side of the picture. Dark side is really black. We don’t have time to spend with our loved once. Our eating habit are totally changed. We are no more regular in life. Stress are always with us like shadow. We are exposed to all deceases exists on this world. And list is endless ……

What is solution for this ? Or solution exists or not ?

I beleive solution is really simple.

1. Be realastics. Don’t waste your time unrealistic goals.
2. Find happiness in daily life’s small things. This is key to happiness..
3. Make environment around happy.
4. Whatever you are doing , do it happily.
5. Follow your heart. We have lot of time to do everything but unfortunately don’t have time to hear voice of 6. heart. Find some time to listen what is your heart is saying.
7. Identify things that makes you happy. It is not difficult. You know what makes you happy try spend most of things there.
8. Find the place to open your heart. Some time you want to speak something but unfotunatly nobody is hear you. Put some efforts build some relations around you.


Part 1.. to be Continue….

Friday, July 4, 2008

Let's listen to our heart.

Welcome !!!

How is life going on? Boring ? Yes , it will boring if we are not accepting enough given by god. If god has given eyes , we should the see beautiful world , stars and infinite things he has created for us. If he has given ears , we should listen the music. If he has given brain ,we should use it.


Everytime we want to say something. We are not ready to listen. Here we are loosers. Let's listen. Let's listen to god. Let's listen to our heart.


We need to explore life ....

About Me : I am Mahendra. Computer Engineer . God has gifted me sensitive mind. I always like to help other. I want to see everyone happy around me. I have founded small oraganisation called “ Shivchatrapati Gramvikas Pratisthan, Wadgoanpeer “ at my village Wadgoanpeer which is in western Maharashtra , India.
There are always storms going in my mind. Some times they are personal, sometime because political and social reason. I am finding place express myself and I found this is best place. Keep visiting here. I promise this blog will be very frequently updated with something new. Till then ... bye ..

Mahendra