-ksh: revenue_ext.ksh: not found [No such file or directory]
I believe there may be some carriage returns causing this error here. I was able to reproduce the error successfully.
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.
Tomino5
Updated on September 18, 2022Comments
-
Tomino5 over 1 year
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-
Ramesh almost 10 yearsWhat is the output of
cat -v revenue_ext.ksh
? -
sonal almost 8 yearsIf you have moved this file from windows to unix Then run dos2unix filename filename command
-
-
Tomino5 almost 10 yearsYes 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:)
-
Арсений Черенков about 3 yearsthis 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.