2

I copied my executable file to Android '/data/local/tmp' directory using

adb push /home/build/bin/myexec /data/local/tmp

I then changed the permission of the executable

chmod 755 myexec

When I tried ./myexec

I got this /system/bin/sh: myexec: not found

I understand that it is not working because it is not on the system's bin folder. Is it possible to run executable through the Android's shell or through an Android app?

Onik
  • 19,396
  • 14
  • 68
  • 91
Doha
  • 325
  • 2
  • 13
  • 1
    There is no need to `chmod` an executable under `/data/local/tmp`. Files under the directory are world-executable. If you used the full path to the file, i.e. `/data/local/tmp/myexec`, and it wasn't working, the problem probably is with the executable itself. What error message do you get in this case? Was it you who compiled the executable? If not, it might not fit to your device's CPU. If so, [Building executables for Android shell](https://stackoverflow.com/q/35231168/3290339) might help. – Onik Dec 23 '17 at 16:24

2 Answers2

1

If running the executable with a full path to it doesn't work, the problem might be with the executable itself, meaning it either

  • wasn't successfully compiled, or
  • was compiled for another CPU, not the one your device had.

In this case the options you have are as follows:

  • if you have access to the source code, compile it for your device's ABI,
  • if it is a 3rd party executable, ask for an executable compiled for your device's ABI (or, if possible, find it yourself).
Onik
  • 19,396
  • 14
  • 68
  • 91
  • 1
    checking device ABI with command `adb shell getprop | grep abi`. Not sure checking executable architecture: `file `. – 404pio Jun 08 '21 at 09:25
0

Use full executable path

/data/local/tmp/myexec

Or change directory first:

cd /data/local/tmp/
./myexec
Artyom
  • 1,165
  • 14
  • 22