|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Basic question on shell script execution
I have two shell scripts in the different directories listed below, Code:
/root/dev/dir1/test.sh /root/dev/dir2/master.sh I am executing the master.sh script from the test.sh like below and getting 'Permission denied' error. Code:
#! /bin/sh #test.sh path='/root/dev' $path/dir2/master.sh But it works fine after including a '.' infront of the script and it works fine. Please see below for the change, Code:
#! /bin/sh #test.sh path='/root/dev' . $path/dir2/master.sh Please explain the concept behind this and let me know is there any way to execute the master.sh in dir2 without the '.' symbol |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
What are the permissions on the
dir2/master.sh script? Is it executable?
By using . (dot) you are "sourcing" the script into your current environment, and it's run from there. If you want to run it the way you have, it needs to be executable. |
| The Following User Says Thank You to Scott For This Useful Post: | ||
vel4ever (07-30-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I have added the below code piece and found the file is not executable Code:
if [ -x $path/dir2/master.sh ] then echo "Executable" else echo "Not executable" fi ---------- Post updated at 04:55 AM ---------- Previous update was at 04:39 AM ---------- Thank you Scott. I wasn't facing this problem earlier and my profile has been reset. I guess this is the root cause. |
| Sponsored Links | ||
|
![]() |
| Tags |
| shell bash |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question about a basic shell script: How to make sure it receives only one input? | 2358 | Shell Programming and Scripting | 3 | 11-29-2011 02:48 AM |
| Basic shell script help | kylecn | Shell Programming and Scripting | 7 | 06-16-2011 10:25 PM |
| Basic Shell Script Help | c4391 | Shell Programming and Scripting | 1 | 03-24-2010 01:35 AM |
| Basic script question | suphawk | Shell Programming and Scripting | 4 | 01-21-2010 12:31 PM |
| basic shell scripting question | convenientstore | Shell Programming and Scripting | 3 | 05-27-2007 10:21 PM |
|
|