I am getting the same not found [No such file or directory] error when trying to execute a ksh script. Read tips about the PATH and running the script with a ./ in the posts here and here and tried but no luck. The script does exist under the directory from where I am trying to execute and has full permissions but gives the same error when run directly or with a ./. The first line within the script also has #!/usr/bin/ksh

The error message is like below:

-ksh: revenue_ext.ksh: not found [No such file or directory]

However, other ksh scripts under the same directory run fine so am absolutely clueless about what could be wrong here. Any help would be greatly appreciated

  • What is the output of cat -v revenue_ext.ksh?
    – Ramesh
    Jun 5, 2014 at 4:00
  • If you have moved this file from windows to unix Then run dos2unix filename filename command
    – sonal
    May 31, 2016 at 8:18

3 Answers 3


I believe there may be some carriage returns causing this error here. I was able to reproduce the error successfully.


cat ksh_experiment.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.

  • Yes you are right.There were ^M characters within the file that were not easily visible to the naked eye. Gave dos2unix revenue_ext.ksh and it worked:)
    – user68112
    Jun 5, 2014 at 5:14

In my case, I had this same error message come up if the file is either .ksh or .sh like this:

-ksh: ./somefile.sh: not found [No such file or directory]

Turns out its the access issue.

Even though you make this file executable, on the server you might need admin rights to run. I could run command line, but executing the script would return not found, try run the script in sudo, then you will know if you are allowed to run the script as root or not.


This happens due to ^M characters.

Try using dos2unix <File_name> and we should be okay to get expected results.

  • this was mentionned in comment of accepted answer. Note to moderator: new commers won't see multiple deleted answer recomending dos2unix I suggest we keep one opened.
    – Archemar
    Apr 20, 2021 at 7:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .