Error : -bash: ./run.sh: /bin/sh^M: bad interpreter: No such file or directory
Occurs when : You copy something from windows to linux and try to execute the .sh file in terminal.
Cause : Copying something from Windows to Linux converts 'line terminating characters' (crlf) from Windows to '^M' in Linux. You can see these by typing the command 'vi fileName.sh'
This can also happen to other (than .sh) files as well. So it is a good practice to follow the following solution whenever you are copying from Windows to Linux OR copying from Linux to Windows.
DOS text files traditionally have carriage return and line feed pairs as their newline characters while Unix text files have the line feed as their newline character. fromdos converts text files from the DOS format to the Unix format, while todos converts text files from the Unix format to the DOS format.
Solution : To remove these '^M', take the following action steps
1. run 'dos2unix' command from terminal. (for all .sh files)
$ dos2unix *.sh
2. If dos2unix is not installed, you can install it by
sudo apt-get install tofrodos
3) For other files you can do dos2unix by
find . -name *.java -exec dos2unix '{}' /;
where,
find - is a command to find the files
. - in current directory
*.java - is a file type in the directory from which you are running the command
-exec - execute the command reccurssively
dos2unix - command to be executed on found files
{} - file name format
; - should end with ';', but as ';' special char, prefixed with '/'
Subscribe to:
Post Comments (Atom)
SpringBoot: Features: SpringApplication
Below are a few SpringBoot features corresponding to SpringApplication StartUp Logging · To add additional logging during startup...
-
There was a requirement in which user should be able to download an excel report from application, make some amendments and upload the exce...
-
I was facing 'java.rmi.NoSuchObjectException: Bean has been deleted' for the stateful bean instance. While reading about the error, ...
-
What Is a WebLogic Server Cluster? A WebLogic Server cluster consists of multiple WebLogic Server server instances running simultaneously an...
1 comment:
To run dos2unix on ALL files in a directory run following command
for f in `find * -type f`; do echo "dos2unix $f $f"; done | sh
Post a Comment