As I have posted in the other question, sometimes it is possible to get the file not found error even when you execute the script as ./scriptname
. As I have posted in the other answer, you can test it in your machine.
Testing
cat ksh_experiment.ksh
#!/usr/bin/ksh
echo "Hello"
Now after providing the permissions when I ran the file, it produced the output successfully. Now as discussed over here, I inserted some carriage returns in my file. Now when I ran the script, I was getting the output as,
ksh: ./ksh_experiment.ksh: not found [No such file or directory]
Now, cat -v ksh_experiment.ksh
too produced the same output. Also, if I typed vim ksh_experiment.ksh
, a new file was getting opened.
As discussed in the answer of the link that I provided, I removed the carriage returns using the command,
perl -p -i -e "s/\r//g" ksh_experiment.ksh
After fixing when I ran, I got the output as expected.
Now, you can use dos2unix
as well to convert the file.
export PATH=$PATH:.
to users.profile
– Guru Jul 15 '14 at 22:09PATH=$PATH:.
is considered harmful. – ctrl-alt-delor Jul 15 '14 at 22:12