Gautham Pughazhendhi
Gautham Pughazhendhi

Reputation: 342

Adding a path to PATH variable

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?

Upvotes: 2

Views: 97

Answers (1)

eduffy
eduffy

Reputation: 40214

$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).

Upvotes: 1

Related Questions