2

I have a shell script located under /home/myself/bin directory. I added its path to PATH variable in .profile by adding the line

export PATH=$PATH:/home/myself/bin

Then I sourced my .profile by the command source ~/.profile. Now when I run sh myscript.sh command it shows,

sh: 0: Can't open myscript.sh

Can anyone say me where I am going wrong?

1 Answer 1

1

$PATH tells your shell where to search for executables. In your case, sh is the executable and myscript.sh is just an argument. You need to first make myscript.sh executable:

 chmod +x /home/myself/bin/myscript.sh

Then just run myscript.sh (without the sh).

Sign up to request clarification or add additional context in comments.

Comments

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.