2

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?

3

Looks like a bug in the ubuntu-terminal-app.

The bug description mentions a workaround:

It seems to work when I use bash ./testscript.

The ./ is optional

  • +1. Do you need the ./ ? – Tim May 4 '15 at 13:03
  • @Tim, as far as I understand the rules, no. It doesn't make lookup in PATH when you give filenames to any command (bash, cat, vi, whatever...). – Velkan May 4 '15 at 13:06
2

Whatever it is (a bug or a weird configuration):

./yourscript.sh

does not work on Ubuntu-touch. The workaround is:

bash yourscript.sh
2

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 as noexec:

/userdata/user-data /home none bind 0 0

I have even tried remounting it explicitly as exec using mount -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:

sudo mv /path/to/SCRIPT.sh /opt
ln -s /opt/SCRIPT.sh /path/to

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

  • Thanks a million was wondering why I couldn't get node running ... – ShaneQful Apr 24 '16 at 16:40
0

Try changing the shabang line to

#!/bin/bash

rather than

#!/bin/sh

This will default the interpreter to bash, rather than sh. That should be simpler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.