LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 06-14-2010, 02:26 AM   #1
itismohit
LQ Newbie
 
Registered: Jun 2010
Posts: 8

Rep: Reputation: 0
Difference between source and dot command in Linux


Hi,

I have written a set of aliases in a file.
When i tried to dot it( "Prompt> . filename" ). It said
" .: Permission denied. "
But, when I sourced it ("Prompt> source filename"). It worked perfectly.

Linux manual has one entry for both the commands. Then what am I missing ?
 
Old 06-14-2010, 08:09 AM   #2
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Linux Mint, Ubuntu
Posts: 1,506

Rep: Reputation: 325Reputation: 325Reputation: 325Reputation: 325
Quote:
Originally Posted by itismohit View Post
Hi,

I have written a set of aliases in a file.
When i tried to dot it( "Prompt> . filename" ). It said
" .: Permission denied. "
But, when I sourced it ("Prompt> source filename"). It worked perfectly.

Linux manual has one entry for both the commands. Then what am I missing ?
Check the file's permissions with
Code:
ls -l <filename>
It's probably something like rw-rw-r--; in other words, it's not marked as executable. You'll need to use the chmod command to change the permissions; something like
Code:
chmod 775 <filename>
 
Old 06-14-2010, 08:26 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
@RockDoctor: actually the files don't need executable permissions, just for the fact they are sourced and not executed.

@itismohit: in BASH the . and the source built-ins are synonyms. Historically the . is the name of the source command for the Bourne Shell, whereas source is the name for C-shells.

I suspect your user's shell is not BASH, since it should manage the two versions properly. Unlike C-shells (e.g. /bin/tcsh) that recognize only source and not dot.
 
Old 06-15-2010, 03:39 AM   #4
itismohit
LQ Newbie
 
Registered: Jun 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Dot command on tsch

@colucix

Thanks man. Yes, my shell is tsch.
I completely agree with you, but that entails another question.

I am wondering why am I getting an error of ".: permission denied" and not ".:command not found".

"prompt> which ." on tsch gave me ".:command not found", but typing
"prompt> . " on tsch is giving ".: permission denied."

what is dot being mapped to by tsch ?

Last edited by itismohit; 06-15-2010 at 03:40 AM.
 
Old 06-15-2010, 03:54 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
The C-shell interprets the "command" . as the "current working directory". It tries to execute a current working directory somewhere in the PATH. You can easily verify it using this dummy script:
Code:
#/bin/tcsh -x
.
On my system it results in:
Code:
$ chmod 744 test.csh
$ ./test.csh
.
/usr/bin/.: Permission denied.
The -x option echoes the commands before the execution (first line echoes the dot). As you can see, here the dot (as command) is mapped to /usr/bin/. hence the permission denied error (since a directory has the executable bit, but you don't have permission to actuall "execute" it).

Last edited by colucix; 06-15-2010 at 03:57 AM.
 
Old 06-16-2010, 04:42 AM   #6
itismohit
LQ Newbie
 
Registered: Jun 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Thumbs up

That pretty much wraps it all.
Thanks again.
 
  


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
Bash scripting issue with "source" or . (dot) operator (Cygwin & Ubuntu) brian.hussey Programming 3 01-22-2010 02:11 PM
difference between open source and free source Aryan Linux - Newbie 1 03-29-2009 11:51 AM
what's that dot command in bash scripts? stabu Linux - Software 4 12-07-2006 12:33 PM
LXer: KDE Dot News: Sponsored by OSU Open Source Lab LXer Syndicated Linux News 0 12-16-2005 06:01 AM
useradd not accepting dot so i am not able to use dot in mail id hanu_raob Linux - General 5 05-13-2004 08:04 AM


All times are GMT -5. The time now is 01:32 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration