/bin/bash: cannot excute binary file

I was changing paths and I think I screwed up. My terminal shows


"/bin/bash: /bin/bash: cannot execute binary file"


when it opens


Help?

MacBook Pro, Mac OS X (10.6.8)

Posted on Jun 27, 2011 3:45 PM

Reply
22 replies

Jun 29, 2011 11:53 AM in response to randallin

Hmm 3 posts in this thread while I was constucting mine...


I guess to avoid a full install maybe just sample some of the stuff in /bin with the file command. If you find others that are classed as just data I would be leary of the entire OS install, not just /bin. You could do a full reinstall to be sure but that's potentially painfull if you have some of your own stuff on the boot. Or I guess you can just not worry and when you encounter some other command that isn't executable, since you now know what to look for, replace it like the bash.


It's a tough call and your decision. I guess I would just first sample other random /bin files to see if they are still executable. If bash is the only one that was screwed leave everything else alone for now.

Jun 29, 2011 12:21 PM in response to randallin

I suppose. But if you reinstalled bash with pacifist just quit while you're ahead 😉 Leave it alone for now. You can always do the restore of the entire /bin if you have future problems with the stuff in there. And if that doesn't work, bite the bullet, reinstall.


It's a shame you don't have any backups of your system you could fall back on (I don't recall you mentioning that). I always have two - one online backup updated daily (I don't use time machine) and one offline (backed up less frequently). I also don't keep my home dir on the boot volume and it too has online/offline backups.

Aug 17, 2011 12:21 AM in response to randallin

One other thing to check is the script's file type.


running a "file" on my script file named CollectForOutput returned:

file ./CollectForOutput

CollectForOutput: Little-endian UTF-16 Unicode text


...I was getting the "cannot execute binary file" error from bash because the file encoding was UTF-16.


Re-ouputting the file using ASCII encoding fixed everything... file returned:

file ./CollectForOutput

CollectForOutput: Bourne-Again shell script text executable


... then I was able to double click to run the script.


I didn't check if UTF-8 or any of the other encodings worked... ASCII worked so I'm just running with it.


Your text editor should allow you to set the file encoding to ASCII during save.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

/bin/bash: cannot excute binary file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.