Discuss Executing sh script ./ style in the Linux Help forum on Dev Shed. Executing sh script ./ style Linux Help forum discussing topics including usage, troubleshooting, modules, and distributions. Linux is an open source OS, based on UNIX.
Time spent in forums: 1 Month 1 Week 1 Day 3 h 57 m 31 sec
Reputation Power: 1485
The shebang line (the #!/bin/sh as the first line in a script) just tells the system which interpreter this file is for. Where the script file you wish to run is found is another matter - that is handled by the $PATH environment variable and by how you invoke the script.
By using ./myscript you are telling the system you want to execute the file called myscript which is in the current directory. If it's elewhere it won't be found. Using sh myscript tells the system that you want to load the sh interpreter (which it should find!) then have that load and run the file myscript which, I think, will be searched for in the directories specifed in $PATH.
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
Time spent in forums: 3 h 58 m 32 sec
Reputation Power: 0
Originally Posted by requinix
What shell are you in? Or in other words, where are you trying to run the file from?
I'm in a tcsh environment.
@simon: Yes I'm in the same directory as the script i'm trying to run. But even so, when I try ./myscript I just get a "./myscript: command not found" error.
edit: Ok problem solved....turns out it was because I had started writing the script file on a windows machine so it had stupid windows invisible endline characters on it. Got rid of those and everything is good.