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
is there any way to excute script every N seconds? umen Shell Programming and Scripting 7 03-30-2006 04:06 AM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
Why ' Permission denied' when executing a command? david_wang UNIX for Dummies Questions & Answers 2 05-15-2005 12:26 AM
The file permission ust UNIX for Dummies Questions & Answers 2 05-05-2005 09:18 AM
help! can't excute hassan2 UNIX for Advanced & Expert Users 6 09-10-2002 02:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-08-2008
ashish_uiit ashish_uiit is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 25
Executing file without excute permission.

Hi,

I have a file which don't have execute permission, but still it can be executed by "sh" like as below.
------------------------------------------------------------------
-rw-r----- 1 root other 30 May 8 15:43 test.sh
(svpkg1-nd:root) - ./test.sh
./test.sh: cannot execute
(svpkg1-nd:root) - sh test.sh
I am here
(svpkg1-nd:root) -
-----------------------------------------------------------
Please tell me the difference between these two ways of executions.
In this way other if other users have only read permission still they can execute the file.

Thanks in advance,
Ashish
  #2 (permalink)  
Old 05-08-2008
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
Hi,
here are some ideas but i might be totally wrong:
- in the first case, since test.sh has no exec attribute, you get "cannot execute" error
- in the second case, you are telling the binary-executable 'sh' to run commands you pass as parameters (test.sh) ...
You need to strip out read attribute if you dont want the second case happening
  #3 (permalink)  
Old 05-08-2008
Zarnick Zarnick is offline
Registered User
  
 

Join Date: May 2004
Location: Brazil
Posts: 40
Just to complement andryk answer, if you want to execute it as ./test.sh, you should put the executable flag in it, and you shell script should begin with the line:
Code:
#!/bin/sh
And here's to put the executable flag
Code:
chmod u+x test.sh
  #4 (permalink)  
Old 05-08-2008
ashish_uiit ashish_uiit is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 25
Quote:
Originally Posted by Zarnick View Post
Just to complement andryk answer, if you want to execute it as ./test.sh, you should put the executable flag in it, and you shell script should begin with the line:
Code:
#!/bin/sh
And here's to put the executable flag
Code:
chmod u+x test.sh
This first line is there in file. I am asking for difference of executing first way and second way
  #5 (permalink)  
Old 05-08-2008
zxmaus's Avatar
zxmaus zxmaus is offline Forum Staff  
Moderator
  
 

Join Date: May 2008
Location: /etc/objrepos
Posts: 297
./filexy.sh requires the script to open the shell - what cannot be done without the x permission

doing sh filexy.sh means you open the shell and the script is passive executed in this shell ...

As long as you are allowed to use the shell you can execute the scripts this way

Rgds
zx
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 11:52 PM.


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