Search code examples
androidlinuxshellterminal-emulator

Scripting in Android with terminal emulator


I was a beginner in Linux. And I had no Computer when I wrote this. I used terminal emulator on my Android to run Linux commands. I installed Busybox too. I also had root access.I tried to execute a shell script "sample.sh". The terminal opens but the file was not executed. So I asked "What is the .bat equivalent extension in linux?".

Is this really a very bad question? What was the point in downvoting the question here? I clearly mentioned what I have tried and What happended. And that genuine downvoter never explained the reason. Is this the correct way to treat a newbie. With lots of hatred from my various questions, I lost hope and never used S.O.

So if there is still hope. Can anyone justify the actions?


Solution

  • The equivalent extension is .sh, but you also need the correct shebang line. The first line of a unix script is examined to determine the magic number - you want something like

    #! /usr/bin/env bash
    

    And the file needs to have the executable bit set,

    chmod a+x file.sh