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 ". ./"
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...
Hello All,
I was having a look on threads on the Forum about time calculation but didn't find exactly this issue.
For instance, if we have these 2 dates, begin & end :
20100430235830
20100501000200
Is there anyway, awk, ksh, perl to calculate the difference in sec and get for... (6 Replies)
Hi All,
Can anyone tell me the difference between flavour & distribution?
As we say that - AIX, Linux, Solaris etc are the flavours of Unix & fedora, ubuntu, suse etc are the distributions of linux.
Can anyone explain me, why it is called so.
Thanks in advance.
Amol (6 Replies)
Hi,
what is the difference btwn s and S in setuid , access permissions.
I have to make to change the access permissions of a file to rwsr_xr_r
but if i type in 4655 it changes the file to rwSr_xr_r .
How can I make this change ?
Please suggest. (2 Replies)
I've come stuck when I was making sure the hour of the day was not been two times so that the rest of the script could not be executed.
Seems simple enough.
I used the -a to join the two conditions together and it would run if the conditions was t/f ( it is only supposed to run if was t/t).... (3 Replies)
:confused: Hi All
Can anyone help me in finding the answer of the question mentioned below.
What is the difference between Unix & linux ?
Thanks in Advance to all
CSaha (1 Reply)
ehe may i know what are the difference between Unix & Linux, and what are the advantages of having Unix as well as disadvantages of having Unix or if u dun mind i am dumb do pls tell me what are the advantages as well as the disadvantages of having linux as well. thanks (1 Reply)