Today I was running a Shell Script on linux server that I uploaded from windows OS to Solaris machine.When I initiated that script I get ": bad interpreter: No such file or directory" error on the command line.
Some History behind this issue will make you understand this clearlly :-
Text files are often incompatible across operating systems. Why? Because each operating systems use different markers to indicate the end of a line. This will really create a big mess you up if you are trying to transfer files from one operating system to another.
The carriage return is often referred to by the capital letters CR. On a Macintosh, every line has a CR (^M – 13) at the end.
Under Linux (a variant of Unix), the end of a line is indicated by a line feed. Every line ends with a line feed or LF (^J – 10).
These are 2 characters with 2 very separate numeric representations on a computer. A CR is a 13 in the ASCII table of characters and an LF is a 10 in the ASCII table of characters.
Contributing to the confusion is that fact that Microsoft Windows does things yet another way. Under Microsoft Windows, lines end with a combination of 2 characters — a CR followed by a LF. Symbolically, this is represented as CRLF or carriage return, line feed.
Solution:
I am having ultraedit editor. In this editor when ever you open any file in the status bar it shouws you its type (DOS/MAC/UNIX)
if you want to convert a file from DOS to UNIX
File > Conversions > DOS to UNIX
And if you want to make each file bydefault to DOS/MAC/UNIX Advanced > Configuration > General Tab inside Editing go to "Default file types for new file" and select desired default type.
You can also refer Ultraedit FAQs http://www.ultraedit.com/support/faq.html
OR
Just create a new file inside UNIX and copy paste your DOS type content. When you save it, it will be converted to UNIX.
Your blog is really good. and the effort you have made to write is commendable.
In above case you may use command : dos2unix
[of course you need to install it first on ur linux machine.. 🙂 ]
This will remove all unwanted characters from your file.