LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 07-31-2012, 03:19 PM   #16
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950

Direct execution is when you use the script name itself as the command name, including the relative and absolute path versions in the above discussion.

source and launching a specific shell name as the main command mean that the script becomes an argument to that command, and the file is read, not executed.
 
Old 07-31-2012, 06:01 PM   #17
carwe
LQ Newbie
 
Registered: Aug 2011
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by David the H. View Post
Direct execution is when you use the script name itself as the command name, including the relative and absolute path versions in the above discussion.

source and launching a specific shell name as the main command mean that the script becomes an argument to that command, and the file is read, not executed.
OK, so that would mean that the she-bang is respected when executing a script (using the script name as the command), but not when calling through 'source' or giving the script as an argument to 'sh', 'bash', etc.
 
Old 07-31-2012, 06:54 PM   #18
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
The she-bang notation is used by the kernel when it launches an executable. If it sees the she-bang, it loads the specified interpreter (can be anything at all, not just a shell), and passes the name of the script as its first commandline argument. The interpeter then opens the file, and interprets the contents.
'Sourcing' is done by an already-running shell itself, and is a behavior of those shells (possibly all major shells).

[EDIT] #! - the Unix truth as far as I know it. explains this in some detail.

Last edited by theNbomr; 08-01-2012 at 11:45 AM.
 
  


Reply

Tags
terminal


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
Executing binaries in /usr/sbin/ seems to be broken kriskras Linux - Newbie 6 05-01-2008 07:42 AM
LXer: Executing Signed Binaries in Linux Kernel LXer Syndicated Linux News 0 07-20-2007 10:46 AM
shell scripts to binaries = possible? jhwilliams Linux - Software 5 06-04-2007 09:14 AM
Possible ways to run shell scripts on Windows Uday123 Linux - General 1 04-05-2006 01:48 AM
getting segmentation violation while executing binaries Indkoeti Linux - Software 1 04-01-2006 04:53 PM


All times are GMT -5. The time now is 12:05 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration