Termux-app: problem running bash scripts

Created on 30 Oct 2017  路  12Comments  路  Source: termux/termux-app

Hello, i have problem executing scripts. For instance, let's consider the following one (getip):

#!/usr/bin/bash

ifconfig | awk '/inet addr/{print substr($2,6)}'

i can't execute it using
./getip
but i can using
sh getip
on the first one, i get the error:
bash: ./getip: /usr/bin/bash: bad interpreter: Permission denied
I have termux-exec and proot installed, an i already did termux-chroot

Am i doing something wrong? or is the second option the only way to execute it?
Regards,

Most helpful comment

I think I figure out. I had the script on extSdCard. I move it to home and I had to rewrite it using nano (i previously used an android text editor)

All 12 comments

It's the shebang problem, you can fix the shebang using termux-fix-shebang <script_name>

but shouldn't termux-exec overcome that problem?
i did
termux-fix-shebang getip
and the script get as:

#!/data/data/com.termux/files/usr/bin/bash

ifconfig | awk '/inet addr/{print substr($2,6)}'

but doing ./getip gives me the same error...

Have you restarted termux after installing termux-exec?

yup, several times...

are you logged in via ssh? Did you eventually not terminate the sshd daemon after the package install? What does

    echo $LD_PRELOAD

say?

nop, nop and
/data/data/com.termux/files/usr/lib/libtermux-exec.so

@kurokirasama Hm, even #!/data/data/com.termux/files/usr/bin/bash doesn't work?

Is something wrong with your bash binary? Does running bash work?

Yes.
Running bash works without error nor output...

I think I figure out. I had the script on extSdCard. I move it to home and I had to rewrite it using nano (i previously used an android text editor)

@kurokirasama it is good to hear that you figured out your issue. Here is more important information regarding storage https://wiki.termux.com/wiki/Internal_and_external_storage

@kurokirasama Aha, great that you got it figured out!

./ngrok
( bash: ./ngrok: Permission denied ) Why?

Was this page helpful?
0 / 5 - 0 ratings