The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To give the "unzip" permissions & "create" file permissions Mike1234 HP-UX 3 03-02-2008 05:34 PM
execute a .jil file OSD Shell Programming and Scripting 4 10-05-2007 12:20 AM
execute a .jil file OSD UNIX for Advanced & Expert Users 1 10-03-2007 05:11 AM
help with permissions - execute but not delete reldb UNIX for Dummies Questions & Answers 2 06-01-2007 03:30 PM
Need to execute 2 scripts, wait, execute 2 more wait, till end of file halo98 Shell Programming and Scripting 1 08-01-2006 04:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-21-2007
rakeshou rakeshou is offline
Registered User
  
 

Join Date: May 2007
Posts: 75
Lightbulb Running file without execute permissions

Please explain this strange behavior to me

Code:
bash-2.03$ ls -l abc
-rw-------   1   bashboy  users        319 Sep 21 18:02 abc
bash-2.03$ ./abc
bash: ./abc: Permission denied
bash-2.03$ . abc
Successfully run

I wanted to ask how the file executes without the execute permissions when we source the file.

Thank you
  #2 (permalink)  
Old 09-21-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by rakeshou View Post
I wanted to ask how the file executes without the execute permissions when we source the file.
Simple answer is it's not executing. It's being interpreted by the current shell.

Executing means "exec()" was called, which, in this case, is not the case.
  #3 (permalink)  
Old 09-21-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Isnt this the same case, when a script without execute bit set and passed to the base shell as an argument ?
Code:
zsh script.zsh
Here the file script.zsh is just an argument to the base binary zsh
  #4 (permalink)  
Old 10-16-2008
beatrizrevello beatrizrevello is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 1
Sourcing a script

Unix programming Learning the Korn Shell, p 25, O'Reilly

There are three ways to run a script in Korn Shell (ksh):

1) $ . scriptname
Here you are running the script without creating a subshell, meaning that the new settings will be still in this shell after running the script. It's like copy/paste each line of the script in the shell.
This is also called sourcing because in csh and tcsh this is executed by running: $ sourse scriptname.
Also to run a script this way the script do not need execution permissions.

2) $ ./scritpname
Run the script in a subshell, after the script executes the shell will not have the new settings. Script need execution permissions.

3) $ scriptname
Run the script in a subshell, if . (current dir) is part of your cmd, searches in $PATH. The script needs execution permissions.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0