Scripts in Talk - Permission denied, script invalid

Trying to implement custom commands in Nextcloud Talk. I’ve followed the documentation spreed/docs/ but i’m having some trouble.

Firstly I’m a bit unsure on how to formulate the command:

./occ talk:command:add calculator calculator "/path/to/ \"{ARGUMENTS_DOUBLEQUOTE_ESCAPED}\" {ROOM} {USER}" 1 3

I don’t really know what to put in {ARGUMENTS_DOUBLEQUOTE_ESCAPED}, {ROOM} and {USER}

When i run the command:

sudo -u abc php /config/www/nextcloud/occ talk:command:add test test "/data/myname/scripts/ \"argument\" rdleoknj myname" 1 3

Where rdleoknj is the room id. And myname is my personal name (should this be the name of the bot responding) ?

I get the error:

sh: /data/myname/scripts/ Permission denied
The script is invalid

I’ve tried to give permissions for the file by: chown -R 777 /data/myname/scripts/ but u get the same error.

I’ve also tried placing the file somewhere else but it did not work either.

Can someone help me out? Thanks!

As far as I understand it {ARGUMENTS} {ROOM} {USER} are placeholders that are filled with the user given input, the user id and the room id, but installing the script needs exactly these term so that the script can be successful run.

Nevertheless I got the same problem - I always and up with “script is invalid”, even the demo script causes this error message. And sadly no one answers this question, I found some more who asked for hints what to do without evenb a response…

So using literally those should work. Please note that {ARGUMENTS_DOUBLEQUOTE_ESCAPED} has been removed and will make your script not execute when being used.

It seems there is a permission/user mismatch between the script and the execution. The script should be owned by your webservers user (for me www-data) and it must be executable for them:

ls -la sample-commands/
-rwxrw-r--  1 www-data www-data  664 Mai  8 08:51

It doesn’t work…

“ls -la talkcommands” shows

drwxrwxrwx 2 christoph psacln 4096 Sep 14 20:50 .
drwx–x— 17 christoph psaserv 4096 Sep 14 20:57 …
-rwxrw-r-- 1 christoph psacln 430 Sep 6 21:09
-rwxrw-r-- 1 christoph psacln 4321 Sep 6 21:09 dice.php
-rwxrw-r-- 1 christoph psacln 545 Sep 6 21:09 talktest.php
-rwxrwxrwx 1 christoph psacln 301 Sep 6 21:09 testausgabe.php

When trying to add the command occweb tells me Script ist invalid, tryin the same with Putty from within my nextcloud folder I get “./occ persission denied”. In putty I’m logged in as root. christoph is my username wehn I installed nextcloud and seems to be the webuser, right? dont know what psacln is (group?).
If I would have to log into Putty as christoph I don’t know the password (and the same as my password for my Nextcloud account on that instance doesn’t work).

So what’s still wrong with that? Wounld be very thankful for some hints as I’m not the LInux guy… :frowning:

This command looks different in a docu:

./occ talk:command:add calculator calculator "/path/to/ {ARGUMENTS} {ROOM} {USER}" 1 3

In this case your command should be

sudo -u abc php /config/www/nextcloud/occ talk:command:add test test "/data/myname/scripts/ {ARGUMENTS} {ROOM} {USER}" 1 3

If you do not need to know about room and/or user, simply remove it from the path.

Those parameters will be forwarded to your script, but you do not need to set them. E.g. everybody who will call your script will send they name to the field user. I wrote few scripts also, you can check and test them before to added own.

Check this explanation

Simply check in your installation path to whom belongs your nextcloud, e.g.:

ls -la /var/www/nextcloud/
Output example where user is www-data
ls -la /var/www/nextcloud/
total 160
drwxr-xr-x 13 www-data www-data  4096 Sep 14 09:16 .
drwxr-xr-x 12 root     root      4096 Aug 31 14:06 ..
-rw-r--r--  1 www-data www-data  3124 Sep 14 10:02 .htaccess
-rw-r--r--  1 www-data www-data   101 Sep 14 09:16 .user.ini
drwxr-xr-x 33 www-data www-data  4096 Sep 14 09:16 3rdparty
-rw-r--r--  1 www-data www-data 15752 Sep 14 09:16 AUTHORS
-rw-r--r--  1 www-data www-data 34520 Sep 14 09:16 COPYING
drwxr-x--- 79 www-data www-data  4096 Sep 14 09:16 apps
drwxr-x---  2 www-data www-data  4096 Sep 14 10:02 config
-rw-r--r--  1 www-data www-data  3910 Sep 14 09:16 console.php
drwxr-xr-x 23 www-data www-data  4096 Sep 14 09:16 core
-rw-r--r--  1 www-data www-data  5048 Sep 14 09:16 cron.php
-rw-r--r--  1 www-data www-data   156 Sep 14 09:16 index.html
-rw-r--r--  1 www-data www-data  2976 Sep 14 09:16 index.php
drwxr-xr-x  6 www-data www-data  4096 Sep 14 09:16 lib
-rw-r--r--  1 www-data www-data   283 Sep 14 09:16 occ
drwxr-xr-x  2 www-data www-data  4096 Sep 14 09:16 ocm-provider
drwxr-xr-x  2 www-data www-data  4096 Sep 14 09:16 ocs
drwxr-xr-x  2 www-data www-data  4096 Sep 14 09:16 ocs-provider
-rw-r--r--  1 www-data www-data  3056 Sep 14 09:16 public.php
-rw-r--r--  1 www-data www-data  5235 Sep 14 09:16 remote.php
drwxr-xr-x  4 www-data www-data  4096 Sep 14 09:16 resources
-rw-r--r--  1 www-data www-data    26 Sep 14 09:16 robots.txt
-rw-r--r--  1 www-data www-data  2381 Sep 14 09:16 status.php
drwxr-x---  3 www-data www-data  4096 Sep 14 09:16 themes
drwxr-x---  2 www-data www-data  4096 Aug 16  2019 updater
-rw-r--r--  1 www-data www-data   362 Sep 14 09:16 version.php
1 Like

When you try to use php files, make sure to set php before your script path php /data/myname/scripts/dice.php

1 Like

A big thank you! I was struggling with that for months now (okay, first with a Nextcloud on hosted Webspace, on V-Server now just for a week), but finally I was able to install the scripts right now via occweb. I think my problem last night after changing the rights and non-working scripts resulted on server upgrades that my provider ran yesterday, I forgot about that.

Now my own scripts work, but the calc script doesn’t (command not found), but I font really need that and guess this happens cause it’s just a call for gnu calc and I don’t now if that’s installed…).

Last question: If I need to change thing in the command script do I need to use talk:command:Update or can I just edit the script file as long as the path doesn’t change?

1 Like

You can use the same script and only change content of it.
I do so, create a test script and try all there before to copy it into final version.

1 Like