Thursday, October 2, 2008

Add Copy To / Move To to the Windows Explorer Right Click Menu

Inorder to add Copy To/Move To options either you need to open registry editor or else save the commands in a .reg extension file and double click it.

Procedure:
On desktop create a new file and paste the below information and save it as copyandmove.reg, Double click this file one time and delete it. Right click on any file/folder u will notice the change immediately.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\Copy To]
@="{C2FBB630-2971-11D1-A18C-00C04FD75D13}"

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\Move To]
@="{C2FBB631-2971-11D1-A18C-00C04FD75D13}"

Tuesday, September 30, 2008

Create your own search engine

Its easy to create a search engine in Mozilla firefox using a Addon
"Add Search Bar" -> https://addons.mozilla.org/en-US/firefox/addon/3682.

After creation of a search engine if you want to customize it goto this location
C:\Documents and Settings\Ur_Username>\Application Data\Mozilla\Firefox\Profiles\

Open the profile directory and goto "searchplugins" folder and select the xml file created using above addon and modify it according to ur convenience.

Monday, September 8, 2008

Forgot to mention subject, while writing an official mail??????

Don’t worry……… just follow the simple steps mentioned below and see the result.

Here are the below steps

1.Open your outlook
2.Press Alt+F11. This opens the Visual Basic editor
3.On the Left Pane, one can see "Microsoft Outlook Objects", expand this. Now one can see the "ThisOutLookSession".
4.Click on "ThisOutLookSession".
5.Copy and Paste the following code in the right pane.(Code Pane)

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(strSubject) = 0 Then
Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
Cancel = True
End If
End If
End Sub

6. Save this and now close the VB Code editor and take a breath. From now on, this macro will make sure you do not make the mistake of sending a mail without subject

Sunday, August 31, 2008

To rename a file using inode value

When a file/directory is saved with special character other than underscore('_') then it is difficult to remove/rename it. Inorder to remove that file/directory, first rename to a valid filename.

Procedure:
Goto directory where the file/directory is present.
Run this command:
ls -iltr
copy the inode value associated with that file/directory which you want to rename/remove and put that number in the following command in place of XXXXX and replace newname with your desired filename.

find . -inum XXXXX -exec mv {} newname \;

Wednesday, August 20, 2008

Shell script to find and replace strings

#!/bin/sh
#Script Find a string and replaces it with another string
if [ $# -eq 0 ]
then
echo
echo "Usage: find_replace.sh find_str replace_str ..."
echo
exit 1
fi
for files in $*; do
if [ "$files" = "$1" -o "$files" = "$2" ]
then
a=1
else
mv $files $files.old
sed 's/'$1'/'$2'/g' $files.old > $files
fi
done
rm *.old 2>/dev/null

Thursday, August 7, 2008

Script to replace ^M characters in unix

#!/bin/sh
if [ $# -eq 0 ]
then
echo
echo "This script will replace the ^M line breaks from dos"
echo "Usage replace "
echo
exit 1
fi
tr -s "\r" "\n" < $1 >$1.tmp
rm $1
mv $1.tmp $1
chmod u+x $1


Note: Don't forget to remove ^M characters from this script first

Friday, July 25, 2008

How to get log file from another unix box using shell script

Use run3.sh for getting a remote file to current directory.

cplogs.sh
=========
#!/bin/sh
if [ $# -eq 0 ]
then
echo "Usage: cplogs "
echo "Options"
echo "1: Managed_Server_1.log"
echo "2: Managed_Server_2.log"
echo "3: Managed_Server_3.log"
echo "4: Managed_Server_4.log"
echo "5: Managed_Server_5.log"
exit 1
fi
rm *.log 2>/dev/null
for i in $*
do
case $i in
1) cp /sundev/osmenv01/bea92mp2_user_projects/domains/osm7ClustDomain/servers/managedServer_1/logs/managedServer_1.log . ;;
2) cp /sundev/osmenv01/bea92mp2_user_projects/domains/osm7ClustDomain/servers/managedServer_2/logs/managedServer_2.log . ;;
3) cp /sundev/osmenv01/bea92mp2_user_projects/domains/osm7ClustDomain/servers/managedServer_3/logs/managedServer_3.log . ;;
4) . ./run4.sh ;;
5) . ./run5.sh ;;
esac
done


run3.sh
========
#!/bin/sh
HOST='Ur Ip'
USER='Username'
PASSWD='password'

ftp -n $HOST <quote USER $USER
quote PASS $PASSWD
bi
cd /sundev/osmenv01/bea92mp2_user_projects/domains/osm7ClustDomain/servers/managedServer_4/logs
get managedServer_4.log
quit
END_SCRIPT

Monday, July 21, 2008

How to exit all telnet session at one shot

function stopall
{
if [ $# -eq 0 ]
then
echo "stopall "
echo "1:Kill all the Tail process"
echo "2:Kill all the telnet session(including kill tail process)"
else

if [ $1 -eq 1 ]
then
psef|grep "tail"|awk '{print $2}'|xargs kill -9 2>/dev/null
echo "All Tail process are killed"
elif [ $1 -eq 2 ]
then
psef|grep "tail"|awk '{print $2}'|xargs kill -9 2>/dev/null
psef|grep "ksh"|grep -v `echo $$`|awk '{print $2}'|xargs kill -9 2>/dev/null
kill -9 `echo $$`
else
echo "Please provide correct input"
fi
fi
}