I have started to write Korn scripts on the client's AIX 4.2 servers and there is this small problem that puzzles me.
I code all my scripts the same way:
first line contains :
#!/bin/ksh
I do this console command on every scripts:
chmod +x scriptname
But still, on some occasions, when running a script (ex: called scriptname.sh), I get an error that I do not understand:
/bin/ksh: scriptname.sh: not found.
It does not always happen but when it happens, its when I am trying to run a new script for the first time. Once it starts to happen, the only way to run that script is to :
ksh scriptname.sh
If a script never had this from the start, it will never happen to it. When logging in with my user-id, the first thing I do is sudo su -
Why is this happening ?
Am I forgetting to do something ?
I do not recall if it is happening on specific servers or not.
But can't I run any scripts from anywhere as long as I am in the same folder of it ?
I mean, if it is coded to be recognized by KSH and is executable, then if I am in the same folder, I should be able to run it no matter what's in the PATH ?
added comments ...
I checked on that server and I have ksh in both /usr/bin and /bin . But the PATH does not contain /bin in it. It does have /usr/bin
This is a confusing question - I'm not sure what you mean.
I'm not aware of any 'folders' - maybe directories?
Nope, $PATH defines your.... well, sequence of directories to search for a named executable. If the current directory (.) is not in the list of paths, it will not be searched.