Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make a simple script that will compile test.cpp but I cannot get it to work. I'm running the script like this:

> bash

And getting the following error:

: No such file or directory
g++: no input files line 3: ./test.out: No such file or directory

Here is

g++ -o ./test.out ./test.cpp

I've tried it without the " ./ " and it still doesn't work. I am running Cygwin on Windows 7 with all the proper packages installed (I can compile and run from the shell itself, just not from script).

share|improve this question
Replace ./ with absolute path! For Example: /home/MyName/test.cpp – Sepahrad Salour May 31 '13 at 17:02
You need to run this in the same directory. – Daniel Beck May 31 '13 at 17:03
what are the permissions on the script file? is the execute bit turned on? – Frank Thomas May 31 '13 at 18:21

Did you create with Notepad?  If so, every line ends with a CR (carriage return) and a LF (line feed).  Cygwin and its Unix-like programs cannot handle that; Unix expects lines in text files to end with just a LF (which Unix calls a “new line” character).  Edit your file with a Cygwin editor (e.g., vi or vim) and fix it.  If you cannot do that, try adding “; #” to the end of each line; that should cause bash to treat the offending CRs as comments.

To expand on the above: if my theory is correct, the second line of looks like:

g++ -o ./test.out ./test.cppCR

plus the LF that’s supposed to be there (that bash excludes from consideration).  So, g++ is looking for a file whose name is “./test.cppCR”, which, of course, doesn’t exist.  So it says:

./test.cppCR: No such file or directory

But, because of what a carriage return is, this causes the : No such file or directory to overwrite the ./test.cpp, so : No such file or directory is all you see.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.