I want to run a shell script on my "bq Aquaris E4.5 Ubuntu-Edition" phone in the Terminal App and created a shell script in /home/phablet/Documents/sync.sh
#!/bin/sh
# sync contacts and calendar with OwnCloud
syncevolution owncloud calendar-defaultcalendar
syncevolution --sync slow owncloud contacts
exit 0
The script is executable but returns:
bash: ./sync.sh: /bin/sh: bad interpreter : Permission denied
I'm not sure what interpreter runs on Ubuntu-touch (bash, sh, ??) and I'm also not sure what rights the default user has.
So what's wrong or missing?
Looks like a bug in the ubuntu-terminal-app.
The bug description mentions a workaround:
The
./
is optionalWhatever it is (a bug or a weird configuration):
does not work on Ubuntu-touch. The workaround is:
After some (preliminary) testing, it appears to me that this is not a bug with the ubuntu-terminal-app, but is instead to do with not being allowed to launch executable files from within the home directory. That's why
bash /path/to/file
worked, but/path/to/file
didn't, because bash resides in/bin
.I have tried running a bash script, a python script, and a hello-world g++ compiled c++ program, all with the executable bit set, and none will run when in a subdirectory of
/home
. None will run, whilst scripts and applications in other subdirectories of root run fine.Unfortunately, I am yet to find a solution: there is nothing in
/etc/fstab
to suggest/home
is mounted asnoexec
:I have even tried remounting it explicitly as
exec
usingmount -o remount,rw,exec /home
to no avail. Will update if I find a solution.So far the only workaround is to use an interpreter to run scripts (Bash/Python etc.) or
/lib/ld-linux-armhf.so.3 /path/to/file
for binary applications.Minor update: A slightly more elegant workaround is to move the script/application to another directory, such as
/opt
, and then symlink to it. That way you can run it just by/path/to/symlink
. For example, you could do:Then you could just type
/path/to/SCRIPT.sh
to run it.UPDATE WITH SOLUTION
Found out the problem is to do with the apparmor security profile for the terminal app. See my question and answer here: Ubuntu touch – executable files won't launch in /home directory
Try changing the shabang line to
rather than
This will default the interpreter to bash, rather than sh. That should be simpler.