Bash cannot execute binary file

Bash cannot execute binary file

I am very new to linux and shell scriprting. I am trying to run a shellscript from secure shell (ssh) on linux using following commands:

I get this error:

Tried using this command:

I get the same error.

Tried with this command: su — myusername sh path/to/ It is asking for my password and giving me this error: no such file or directory .

1.The result of cat -v path/to/ is: ^@^@^@^@^@^@^@^@Rscript "$dir"/diver_script.R done

2.When tried ‘less path/to/’ i got this on my terminal:

3.When i ran file path/to/ : i got this "Bourne-Again shell script text executable"

Please give any advice on how I can try executing the shellscript.

I couldn’t execute a fortran compiled code in ubuntu 11.10 32 bit.

Error message is

I’ve installed the gcc and gfortran libraries too.

Could anyone help?

6 Answers 6

As you can see from the output of file um that you posted in a comment, your binary is a 64-bit binary.

32 bit systems cannot run 64 bit binaries, it only works the other way around.

Try making the file executable

Then try running it

But if this is a exe file compiled for Windows, you probably need to install Wine.

Another solution for people who are having this problem except the part about unmatched bits is that running the file without the command "bash".

Just use chmod +x ‘path to the file’ and then run ‘the path to the file’ in terminal.This is how I solved my problem.

For Googlers:

  • 32-bit or 64-bit? Check with file yourbinary
  • Permission to execute? Do chmod +x yourbinary
  • Path correct? Do ./yourbinary

Another possible source of this error: trying to run a Linux binary executable on a Mac, or vice versa.

Читайте также:  Awc dll load failed mass effect 2

For instance, trying to run the true binary from my Mac on an Ubuntu box that I SCPed it to:

If you’ve downloaded a binary and executing it fails with this error, check if you’ve downloaded the version for the wrong OS.

I have a script that works well when I ssh to the server to execute it myself, but has problems when Hudson, a continuous integration server, runs it.

I am automating tests on an embedded linux system (the target). The target is connected to Server A (RHEL 5) via serial and operated over minicom. Server B (FC 12) builds the tests that actually run on the target, and can ssh to Server A. Server C (RH) hosts Hudson, with Server B as a slave.

I’ve written a runscript ( script to do everything needed on the actual target; it boots the image, mounts a directory from Server B and executes the tests. A bash script on Server B invokes minicom with the runscript script along with some companion actions. I have a bash script on Server B which uses

to get those tests run on the target. I am on Server C, I can get those tests run by ssh’ing to Server B and executing the script that ssh’s to Server A which executes minicom with runscript. Whew. To review:

Server A: Hudson uses its slave mechanism to ssh to Server B.

Server B: has the line ssh -t -t ServerA

Server A: calls a perl script which invokes minicom -S my.script ttyE1

Target, after booting: Mounts a directory from Server B, where the tests are, and enters that directory. It invokes yet another bash script, which runs the tests, which are compiled C executables.

Читайте также:  Fallout 4 окно диалогов

Now, when I execute any of these scripts myself, they do what they should. However, when Hudson tries to do the same thing, over in the minicom session it complains about a line in the "yet another bash script" that invokes the C executable, ./executable , with ./executable: cannot execute binary file

I still have a lot to learn about linux, but I surmise this problem is a result of Hudson not connecting with a console. I don’t know exactly what Hudson does to control its slave. I tried using the line export TERM=console in the configuration just before running, but the problem remains.

Can anyone explain to me what is happening and how I can fix it? I cannot remove any of the servers from this equation. It may be possible to take minicom out of the equation but that would add an unknown amount of time to this project, so I’d much prefer a solution that uses what I already have.

2 Answers 2

The message cannot execute binary file has nothing to do with terminals (I wonder what led you to think that — and I recommend avoiding making such assumptions in a question, as they tend to drown your actual problem in a mess of red herrings). In fact, it’s bash’s way of expressing ENOEXEC (more commonly expressed as exec format error .

First, make sure you didn’t accidentally try to run this executable as a script. If you wrote . ./executable , this tells bash to execute ./executable in the same environment as the calling script (as opposed to a separate process). That can’t be done if the file is not a script.

Читайте также:  Charger зарядное устройство для аккумуляторов

Otherwise, this message means that ./executable is not in a format that the kernel recognizes. I don’t have any definite guess as to what is happening though. If you can run the script on that same machine by invoking it in a different way, it can’t just be a corrupt file or a file for the wrong architecture (it might be that, but there’s more to it). I wonder if there could be a difference in the way the target boots (perhaps a race condition).

Here’s a list of additional data that may help:

  • Output of file …/executable on server B.
  • Some information about the target, such as the output of uname -a if it’s unix-like.
  • Check that the target sees the same file contents each time: run cksum ./executable or md5sum ./executable or whatever method you have on the target just before yet-another-bash-script invokes ./executable . Check that the results are the same in the Hudson invocation, in your successful manual invocation and on server B.
  • Add set -x at the top of yet-another-bash-script (just below the #!/bin/bash line). This will produce a trace of everything the script does. Compare the traces and report any difference or oddity.
  • Describe how the target is booting when you run the scripts manually and when Hudson is involved. It could be that the target is booted differently and some loadable module that provides the support for the format of ./executable doesn’t get loaded (or is not loaded yet) in the Hudson invocations. You might want to use set -x in other scripts to help you there, and inspect the boot logs from the target.
Ссылка на основную публикацию
Adblock detector