Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting ": No such file or directory" when trying to execute a bash script?

Tags:

git

bash

shell

I'm trying to execute a bash script (git-ftp) but I can't seem to do it. This is what happens:

[trusktr@rocketship ~]$ ~/scripts/git-ftp
: No such file or directory

The file has permissions 755.

This is the contents of the script: http://pastie.org/3567556

Why am I getting this error? What can I do to fix the problem?

like image 471
trusktr Avatar asked Mar 11 '12 00:03

trusktr


2 Answers

I have seen this error if the script has windows line endings instead of unix line endings. Try running dos2unix on the script and see if you get the same error.

like image 78
joesdiner Avatar answered Sep 30 '22 05:09

joesdiner


Is there a #! (hash bang) line in the script, and does the pathname resolve?

If the script is running, it may be something in the script. Add this command to the top of the script, before any other command (but of course after the hash bang, if there is one):

set -x   # enable trace mode
like image 26
Kaz Avatar answered Sep 30 '22 05:09

Kaz