Difference between ./ & . ./ ???

For executing a shell script, i know 2 ways:
1) using sh command
2) making the script file executable & then use ./

But i can across another way for executing the scripts... using ". ./"
I tried this way.. but i was able to understand the difference between "./" and ". ./"

I would be very grateful if any1 can help me????? :confused:

Thanx in advance

When you make a script executable and invoke with ./myscript, you are specifying the path to the script (i.e. "." - the current directory). The script will then be interpreted by whatever interpreter you've sepcified in your shebang line (#!/bin/sh, for example) at the top of the script. This script will be executed in a child shell, and any variables set in the parent shell that aren't exported will not be available to the child. Also; even if you export variables in your script, they still won't exported "up" to the parent.

If you had the current directory (".") at the end of your PATH, i.e. PATH=$PATH:. you could then omit the ./ part. This is particularly bad form, and is a security risk, so I would err against this under all circumstances! It's far safer to explicity say you want to execute a script in the current directory by specifying the path (./).

When you type . ./ you are executing the commands contained within the script in the current environment, so that, for example, any variables set in the current environment that aren't exported become available to your script, and any variables set in your script become available in the current environment... observe...

$ a=1
$ cat > my_script
echo a is $a
b=2
$ . ./my_script
a is 1
$ echo $b
2

Cheers
ZB

Thanx zazzybob.. for your reply..
I am very thankful for your explanation....