termux / termux-boot

Termux add-on app allowing programs to be run at boot.
https://f-droid.org/en/packages/com.termux.boot
973 stars 224 forks source link

Write a script #24

Closed paulsavo1 closed 5 years ago

paulsavo1 commented 6 years ago

Hi im new to this and a bit lost, im trying to get a programm to run on start

i have created the boot folder and know how to copy .sh file into it and have used
logcat -s termux:* and can confirm that the .sh file is booting at startup but the program is not actually starting so im obviously not getting the script right

im trying to start a program called sstvProxy.py

it is located here /sdcard/sstvProxy/sstvProxy.py

what i have put in my .sh file is this

!/bin/bash

python /sdcard/sstvProxy/sstvProxy.py -hl

but it is not working

can someone please help as im really struggling

Grimler91 commented 6 years ago

Hi, #!/bin/bash isn't a valid shebang in termux (nothing exists at that location) so you need to change it to /data/data/com.termux/files/usr/bin/bash. Also make sure it is executable: chmod u+x path/to/your/script

paulsavo1 commented 6 years ago

cheers for response so is that what proper script look like

/data/data/com.termux/files/usr/bin/bash chmod u+x python /sdcard/sstvProxy/sstvProxy.py -hl

Grimler91 commented 6 years ago

Well, almost.

Try

#!/data/data/com.termux/files/usr/bin/bash
python /sdcard/sstvProxy/sstvProxy.py -hl

And you might need to run chmod u+x ˜/.termux/boot/your_script_name to make it executable.

paulsavo1 commented 6 years ago

does the chmod bit just get added after the 1st 2 lines?

Grimler91 commented 6 years ago

Try without the chmod part first.

You can learn more about what it does here: https://askubuntu.com/questions/443789/what-does-chmod-x-filename-do-and-how-do-i-use-it

paulsavo1 commented 6 years ago

ok so its not starting on boot but the script is correct as when i manually input below into termux it runs my sstvProxy.py program so, is how can i actually get it to execute? im confused as when i type logcas - s termux:* it says that my sstvProxy.sh file is running

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

python /sdcard/sstvProxy/sstvProxy.py -hl

Grimler91 commented 6 years ago

If the logcat says that it is running then I would assume that it is running but that something is wrong in the sstvProxy.py script

paulsavo1 commented 6 years ago

cheers can you point me to what it might be, the command to run the actual py file is just simply

python /sdcard/sstvProxy/sstvProxy.py - hl

so what should the script look like to run this in termux/boot

paulsavo1 commented 6 years ago

ok mate it is something to do with termux or termux boot although it is saying in logcat that it is running i dont think it is, as when i simple type ~/.termux/boot/sstvProxy.sh the program starts, so the script must be correct, is there something preventing it from opening

Grimler91 commented 6 years ago

when i simple type ~/.termux/boot/sstvProxy.sh the program starts

What does "the program starts" mean? How are you verifying this? What does the script actually do?

I would try to replace the script with something else that is easy to verify, like

#!/data/data/com.termux/files/usr/bin/bash
echo `dateˋ >> ˜/boot.log

If that works then you know it is executed, if it doesn't work then the problem is with termux-boot

paulsavo1 commented 6 years ago

hi the script is supposed to input a python command at startup that i would normally have to input manually.

It is a program that runs a proxy iptv m3u8 url so i can access on other devices

I know the script seems to work as when i just input manually the folder it is located in, then the proxy program starts and data is sent to my devices

i am in work so i will try the other script when i get home

paulsavo1 commented 6 years ago

any idea mate?

Grimler91 commented 6 years ago

How did the date script go?

Grimler91 commented 5 years ago

@paulsavo1 I'm still waiting for a report on how the date script went, did that work?

From your comment in https://github.com/termux/termux-tasker/issues/18 it sounds a bit like you've solved this issue, is that the case? Sharing the solution would then help others and you could close this issue to indicate that it is solved.