3

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

asked Apr 22, 2016 at 4:20
5
  • Is there a "hashbang" in the file? #!/bin/sh or #!/usr/bin/env bash or 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 using which sh. Commented Apr 22, 2016 at 14:02
  • Please look my update Commented Apr 22, 2016 at 14:07
  • 1
    Then just modify the script to have the correct path there. Commented Apr 22, 2016 at 14:10
  • You say that I need to use#!/system/bin/bash instead of #!/bin/bash ?? Commented Apr 22, 2016 at 14:13
  • Thanks this worked. I forgot modify it for Android. Thanks. Commented Apr 22, 2016 at 14:28

1 Answer 1

2

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.

answered Apr 25, 2016 at 13:58
1
  • Is there an env in AOSP? Commented Jan 30 at 22:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.