Basic question on shell script execution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Basic question on shell script execution
# 1  
Old 07-30-2012
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
# 2  
Old 07-30-2012
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.
This User Gave Thanks to Scott For This Post:
# 3  
Old 07-30-2012
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Dumb question on script execution

Hi Folks - I have a dumb question. Why does this work: pushd "/apps/scripts" ./script.sh popd But this doesn't: ./apps/scripts/script.shIs it that obvious where I'm overlooking it? (7 Replies)
Discussion started by: SIMMS7400
7 Replies

2. Programming

Solr--Basic Example execution error

Hello , I am new bee to Solr and trying to run sample example for solr . java -Durl=http://locahost:8983/solr/update -jar post.jar books.csv Error SimplePostTool version 1.5 Posting files to base url http://locahost:8983/solr/update using content-type... (3 Replies)
Discussion started by: Tomlight
3 Replies

3. UNIX for Dummies Questions & Answers

Basic loop awk/shell script question..

Hi, Sorry if this is a newbie question. I guess you can use either awk or shell script for this sequence of operations, but knowing very little about either of them I'm not sure how I should try to write this. The basic objective is to copy certain files that are scattered all over my... (10 Replies)
Discussion started by: pc2001
10 Replies

4. Shell Programming and Scripting

Question about a basic shell script: How to make sure it receives only one input?

Hello all! I am very new to shell and Linux in general (I just started 2 days ago), I am trying to write a script that adds the size of the directories and files in a given directory and displays messages if the user puts in something wrong. I think I have covered all the possible problems except... (3 Replies)
Discussion started by: 2358
3 Replies

5. Shell Programming and Scripting

Basic shell script help

Im trying to make a script that simply adds a word to the last available line in a txt file without overwriting any previous lines. Ive googled this and there are great examples but no one explain what each function does, and i dont entirely understand how it works. Basically Im looking for... (7 Replies)
Discussion started by: kylecn
7 Replies

6. Shell Programming and Scripting

Basic Shell Script Help

Lets say I wanted to create a script that would show what people are doing on my machine using the w command and refresh in about 6 seconds. What would be the easiest way to do this? I pretty much want the script to loop until I stop it. I'm using the BASH shell by the way. Help is appreciated.... (1 Reply)
Discussion started by: c4391
1 Replies

7. Shell Programming and Scripting

Basic script question

I'm trying to approach a problem but all I'm coming up with are complex ways to manipulate the data. But still not getting the desired outcome. directory of files.... file-100-foo file-100-man file-100-chu Need to copy the files and increment the number in the file name ... (4 Replies)
Discussion started by: suphawk
4 Replies

8. Shell Programming and Scripting

Basic Shell script syntax help

Hi All, I am new to shell scripting. I have a variable which holds a numeric value.I have to check whether this variable holds a value between(0- 8),(8-17)(17-24).How do i write this syntax using if in shell scripting. Thanks Vignesh (2 Replies)
Discussion started by: vignesh53
2 Replies

9. Shell Programming and Scripting

need a quick basic shell script help

im trying to run the below if command ifconfig -a |grep 10.100.120.21 gives me below output inet addr:10.100.120.21 Bcast:10.100.120.255 Mask:255.255.255.0 i just want a basic shell which says if above exists then continue how would i do this? (6 Replies)
Discussion started by: eb222
6 Replies

10. Shell Programming and Scripting

basic shell scripting question

If I did indeed grep something out of it, why woudln't $result show nothing? When I do $? , it does show success... What is the proper syntax so that $result shows actual thing it's grepping out? result=`(ssh $host tail -1 /something/somethingelse) | egrep -i "value" >dev/null` #echo... (3 Replies)
Discussion started by: convenientstore
3 Replies
Login or Register to Ask a Question