Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 while others can not. As a work around, I had to copy the file that's executable and replace its contents with what's from the file couldn't be executed. It worked for me, but just want to know what caused this problem. For sure it's not the path issue since other files in the same directory can be called. It's not because of file not executable either, since I made sure for that. 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
share|improve this question

migrated from stackoverflow.com Aug 20 '10 at 21:26

This question came from our site for professional and enthusiast programmers.

3  
Compare the shebang line of the two scripts carefully –  Vardhan Varma Aug 20 '10 at 18:23
1  
Are you saying that blastem and bbrBlas have the same contents, yet one runs while the other doesn't? If so, they have different file sizes, so they definitely don't have the same contents. –  Jeff Aug 20 '10 at 18:28
    
@Jim, please don't open a second question - instead, add more information to your original question: stackoverflow.com/questions/3497277/… –  Jeff Aug 20 '10 at 18:32
1  
bbrBlas is being called, it's just displaying an error when it is run. Post the contents of the script if you need help debugging it. –  John Kugelman Aug 20 '10 at 18:32
    
Thanks for all your replies. No, those are two files with different contents. I used it just as an example two files with the same characterics behave differently. In the past, as I said above, it usually solved the problem by creating a file that can be executed first, then replace its content by copying the contents from the file I had problem with. I just don't understand why. I almost forgot to mention that two files are with the exact same shebang line as: (#!/bin/sh) I'm not really concerned with the contents of the bbrBlas. –  Jim Aug 20 '10 at 19:17
add comment

1 Answer 1

You get this message when the #! line at the top of the script is wrong. The #! interpretation is done in the kernel, and the kernel-process interface only has room for an error code. Thus all your interactive shell can report is the error code (Command not found) and what file it tried to execute (./bbrBlas).

share|improve this answer
3  
particularly check if that line ends in a carriage return -- did you edit the file in a MS-Windows editor and transfer it to a *nix server? –  glenn jackman Aug 20 '10 at 20:05
    
yes. I guess that may be the reason. Unfortunately, I already replaced it with a working version from other location so I could not check it. Will check this if it happens again. Thanks. –  Jim Aug 20 '10 at 20:12
add comment

Your Answer

 
discard

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