0

The following are two shell scripts stored in the same folder with execute permissions on both:

shell1.sh

#!/bin/bash
exec shell2.sh

shell2.sh

#!/bin/bash
pwd

When trying to execute shell1.sh I am getting the following error:

./shell1.sh: line 3: exec: shell2.sh: not found

Is there something I am doing incorrectly? This works in other machines though but just in one particular server its not working.

Any suggestions would be helpful.

0

1 Answer 1

5

The current dir is not part of your PATH. Try

exec ./shell2.sh
Sign up to request clarification or add additional context in comments.

3 Comments

I figured out the problem, the server where it was working had . in the path which meant the current directory was always in the path. Thanks for you input.
Fix it correctly, by being explicit (like this or more so), and remove "." from the path on that server!
Can you accept this answer? Btw, Chris means: A dot in your path is dangerous, better remove it on the other server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.