22
#!/bin/bash
cd ~/workspace/trunk;
svn up;

When I run ./build.sh form command line, it says:

: command not found

And nothing happens. How can I solve this ?

0

5 Answers 5

60

I solved adding execute permissions:

sudo chmod +x file.sh

Sign up to request clarification or add additional context in comments.

Comments

19

I Have resolved my error from this command.

sudo chmod +x build.sh

Comments

15

My guess is that you have unprintable control characters in the file, or it has \r\n (CRLF) line endings (dos/windows mode).

Try checking it with these commands:

$ hexdump -C build.sh 
00000000  23 21 2f 62 69 6e 2f 62  61 73 68 0a 63 64 20 7e  |#!/bin/bash.cd ~|
00000010  2f 77 6f 72 6b 73 70 61  63 65 2f 74 72 75 6e 6b  |/workspace/trunk|
00000020  3b 0a 73 76 6e 20 75 70  3b 0a                    |;.svn up;.|
0000002a

$ file build.sh 
build.sh: Bourne-Again shell script, ASCII text executable

$ unix2dos build.sh 
unix2dos: converting file build.sh to DOS format ...

$ hexdump -C build.sh 
00000000  23 21 2f 62 69 6e 2f 62  61 73 68 0d 0a 63 64 20  |#!/bin/bash..cd |
00000010  7e 2f 77 6f 72 6b 73 70  61 63 65 2f 74 72 75 6e  |~/workspace/trun|
00000020  6b 3b 0d 0a 73 76 6e 20  75 70 3b 0d 0a           |k;..svn up;..|
0000002d

$ file build.sh 
build.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators

2 Comments

I'll bet you $5 that it's really build.sh, but kudos for biuld.sh example :D
I just used OP's filename :P Yeah, i bet it's build.sh too
12

None of the above worked for me except

sudo ./build.sh

Comments

7

Remove ; from the end of your script lines.

This doesn't happen in my bash, so I'm not sure what exactly is wrong, but my guess is this:

; is a separator of commands. Since your last command ends in ;, your bash probably expects another command after. Since the script finishes, though, it reads an empty command, which it can't execute.

5 Comments

While the semicolons are unnecessary, they don't actually cause the issue given here -- worst-case you'd get a syntax error if you had two command-terminating sigils next to each other.
@CharlesDuffy, probably. However, I don't know what bash the OP is using. Since the error didn't happen in my bash, my guess is that his version is different, possibly expecting something to come after ;. The error message indicates <nothing>: command not found which implies his bash does in fact try to execute <nothing>!
Not necessarily <nothing> -- more likely, it's trying to execute $'\r', which simply renders as nothing.
@DennisWilliamson, no the error message is enclosed in double quotes, most probably by the OP. There is one " in the end of the message also!
This answer is simply wrong. When a script uses normal (UNIX-format) line endings, trailing ;s are harmless -- you can easily test this yourself. It's only DOS line-endings that make this error trigger.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.