Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts started from widget cannot execute other scripts #37

Closed
EnsignCrasher opened this issue Nov 12, 2019 · 2 comments
Closed

Scripts started from widget cannot execute other scripts #37

EnsignCrasher opened this issue Nov 12, 2019 · 2 comments

Comments

@EnsignCrasher
Copy link

I'm trying to run scripts on /storage/emulated/0 from the widget and as symlinks did not work I tried to "meta-script" in .shortcuts with starts my script in /storage/emulated/0.
Thereby I noticed ,if you run a script in .shortcuts through the termux-widget, it will always tell "file not found" when accessing other files.

so here are the steps to reproduce to make it clearer:
.shortcut/test.sh:

#!/bin/sh
path="$(cd "$(dirname "$0")" && pwd)/test2.sh"

$path

ls -lah "$path"

sleep 10

.shortcut/test2.sh

#!/bin/sh
printf "hello world\n"

then run:

chmod +x .shortcut/test.sh
chmod +x .shortcut/test2.sh

and then execute test.sh in termux-widget

error when executing the script: [path-to-test2.sh] not found
ls will show that the file exists

if you run the scripts from the command line it will work as well

@ghost
Copy link

ghost commented Nov 12, 2019

Replace

#!/bin/sh

with

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

@ghost
Copy link

ghost commented Nov 12, 2019

You cannot use "standard" shebangs with widgets.

EDIT:
Also, you can't execute scripts directly from /storage/emulated/0. Call them with interpreter (e.g. bash /my/script.sh) - it will bypass shebang & exec permission issue and script will run.

@ghost ghost closed this as completed Nov 12, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant