LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-14-2006, 03:22 AM   #1
binary_0011
Member
 
Registered: Apr 2006
Location: Singapore
Distribution: RHEL4,FC4,FC5
Posts: 89

Rep: Reputation: 15
dot space dot


can someone tell me why do i have to specfic . ./setup.sh (notice the space) ?

wat does the "space" in between the dots mean?

Thanks.
 
Old 09-14-2006, 03:44 AM   #2
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
The first '.' is the command 'source' to read and execute commands from the filename given as argument.
The second '.' is the current directory.
. ./setup.sh
is the same as
source ./setup.sh
or
source setup.sh (if the ./, the current directory, is in the PATH environnement variable).
 
Old 09-14-2006, 04:07 AM   #3
binary_0011
Member
 
Registered: Apr 2006
Location: Singapore
Distribution: RHEL4,FC4,FC5
Posts: 89

Original Poster
Rep: Reputation: 15
lol, i still dont get it, cant we just enter ./setup.sh ? in wat kind of circumstance we need to enter 2 dots?

Thanks.
 
Old 09-14-2006, 04:25 AM   #4
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
With the 'source' or '.' command the script need not be executable.
If you use ./setup.sh the file must be so (eg 'rwxr-xr-x' permissions).
 
Old 09-14-2006, 05:02 AM   #5
binary_0011
Member
 
Registered: Apr 2006
Location: Singapore
Distribution: RHEL4,FC4,FC5
Posts: 89

Original Poster
Rep: Reputation: 15
alright , i got it.

thanks.
 
Old 09-14-2006, 07:43 AM   #6
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
But more importantly:
- If you use the "source" or "." keywork, the script is executed in the current environment, which means that changes to variables (eg: PATH) or other (eg: cd /some/directory/) are still valid.
- Else such changes are forgotten when execution is done.

Example:

Code:
(/home/yves)$ echo $PATH
/bin:/usr/bin:/usr/X11R6/bin
(/home/yves)$ cat test.sh
export PATH=/usr/local/bin:$PATH
cd /usr/local
echo $PATH
pwd
(/home/yves)$ ./test.sh
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
/usr/local
(/home/yves)$ echo $PATH
/bin:/usr/bin:/usr/X11R6/bin
(/home/yves)$ . ./test.sh
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
/usr/local
(/usr/local)$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
Notice how things remain changed when the script is sourced.

Yves.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
useradd not accepting dot so i am not able to use dot in mail id hanu_raob Linux - General 5 05-13-2004 07:04 AM
MIKEROWSOFT dot COM joesbox General 31 01-23-2004 05:16 PM
Linux dot com interview macewan General 2 01-08-2004 10:02 AM
What is dot vrdprasad Linux - General 1 11-08-2003 05:57 AM
dot and dot dot gag Linux - Newbie 4 10-17-2003 05:57 PM


All times are GMT -5. The time now is 07:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration