tags:

views:

63

answers:

3

I encountered some weird bahavior on my linux system. I created some bash script files, and changed their mode to be executable. However, some can be called and executed, while others can not (with err msg of command not found). As a result, I had cp a file based on the one which was able to be found and executed, then replaced the newly created file with the contents from a file which could not be executed as an ugly work around. It worked for me, but just want to know what caused this problem. It would be great if anyone know a quick fix since this problem is recurring.

For example, you can see the system is able to run blastem, but not bbrBlas

[c052308@sander ~]$ /home/c052308/bbrBlas -d ./BBR -l pt -p prior.txt -r
/home/c052308/bbrBlas: Command not found.
[c052308@sander ~]$ ./blastem

[c052308@sander ~]$ ./bbrBlas
./bbrBlas: Command not found.
[c052308@sander ~]$ ls -l bbrBlas blastem
-rwxr-xr-x 1 c052308 sashare 3108 Aug 18 17:03 bbrBlas
-rwxr-xr-x 1 c052308 sashare  798 Aug 12 12:06 blastem
A: 

Do they all have the same she bang line (i.e., #!/bin/bash or something like it)

rich
yes, it had the same line since I usually copy it from file to file
Jim
This is not an answer. This type of post should go into the comments.
Jeff
A: 

As a first step, I'd suggest doing ls -lon the suspicious files and post the result. There might be some notable differences in the permission.

Nicolas78
that's what I did and I could not find out any difference between files.
Jim
Please post the result, as suggested by nicolas78. Perhaps it's some tiny difference that you have accidentally missed.
Philipp
-rwxr-xr-x 1 c052308 sashare 594 Aug 16 17:02 newinput-rwxr-xr-x 1 c052308 sashare 22 Aug 16 16:34 callniptwhere newinput is executible and callnipt is not
Jim
This is not an answer. This type of post should go into the comments.
Jeff
+1  A: 

Make sure that your shebang line (i.e. first line, starts with #!) does not contain \r (0x0d) which may happen if you edited your script under DOS or Windows. Actually, make sure that your script does not contain any weird characters -- use hexdump -C to find them.

Roman Cheplyaka