I wanna run my script which is located in system/bin and permissions is 755.
With sh myscript there is no problem but myscipt or ./myscript doesn't work even if the pwd output is /system/bin.
On ubuntu I just need to put in /usr/bin and after setting permissions, I can run it easily. I wondered that why I have to put sh in everytime I typed it.
For example I push the aria2 binary file to /system/bin (755) and I can easily run with typing aria2c. I now that this is not script but they are same thing what I tried.
Update
I have hashbang like #!/bin/bash and which sh output is /system/bin/sh
1 Answer 1
To have it answered: Android has different filesystem layout, and bash is at (from linux PoV non-standard location) /system/bin. That's why script was working on linux (Ubuntu) and not on android.
For non-native executables (e.g. bash, python etc.) to work the "hashbang" (#!) has to be updated to contain correct path to interpreter (#!/system/bin/bash).
If there is /usr/bin/env on android, using #!/usr/bin/env bash would make the script portable.
-
Is there an
envin AOSP?RokeJulianLockhart– RokeJulianLockhart2025年01月30日 22:21:53 +00:00Commented Jan 30 at 22:21
#!/bin/shor#!/usr/bin/env bashor something like that? Either there is no such line, or there is one but with wrong path. No idea what the correct path on adroid would be though. Get that usingwhich sh.#!/system/bin/bashinstead of#!/bin/bash??