LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 01: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, 07:09 AM   #2
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Manjaro
Posts: 1,791

Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
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, 07:26 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
@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, 02: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 02:40 AM.
 
Old 06-15-2010, 02:54 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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 02:57 AM.
 
Old 06-16-2010, 03: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



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 01:11 PM
difference between open source and free source Aryan Linux - Newbie 1 03-29-2009 10:51 AM
what's that dot command in bash scripts? stabu Linux - Software 4 12-07-2006 11:33 AM
LXer: KDE Dot News: Sponsored by OSU Open Source Lab LXer Syndicated Linux News 0 12-16-2005 05: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 07:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:30 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
Open Source Consulting | Domain Registration