Can't make OCC command work

Hi,

I have a debian x64 server (8.5) and was running OC 9.0
I tried to update to OC 9.1 on the way I was used to: apt-get update followed by apt-get upgrade. I disabled the maintenance mode in config.php and normally I coud update the database from my web server. Now OC says it is too big and I have to use the command line updater. That's where I am stuck!

I found out my http user is root (really bad I know, but it's not the point right now), so my command would look like "/bin/su root occ upgrade" However, when I do this in the installation folder of my owncloud (it's default, /var/www/owncloud ) I get:

occ: line 2: ?php: No such file or directory
occ: line 3: /bin: Is a directory
occ: line 4: syntax error near unexpected token `('
occ: line 4: ` * Copyright (c) 2013 Thomas Müller <.... >'

And when I do
/bin/su root php occ upgrade
I get
/usr/bin/php: /usr/bin/php: cannot execute binary file

Also when I locate the php directory or use an other command then upgrade (ex. /bin/su root /usr/bin/php occ status) I get the same message.

I don't understand how to use the occ command on an other way. Can someone help?

---- edit ----
The owner of my config.php file seems to be www-data, so I got that far I typed:
/bin/su www-data php occ status
This gives me: This account is currently not available. According to this topic it should stay this way. What's the correct way of using occ command?

I tried to enable the login anyway, but I keep getting 'cannot execute binary file'. :frowning:

First, go through the official documentation: https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/occ_command.html
There are example of occ commands there.

Second,

I think the error is clear. You should ask yourself why you cannot execute that binary: is it installed (for ubuntu the package name is "php5-cli")? is it installed in the expected place (/usr/bin/php)? Does it have the correct permissions?

As a side note, I'd be grateful if you edit the title: "OCC command doesn't work" implies a bug in the code, which isn't the case; "I can't make OCC command work", or "OCC command doesn't work for me" implies you need help. :wink:

Thanks for your reply.
I went through the official documentation but can't even get the first command work...
"/bin/su www-data php occ" gives the above error.

php5-cli is intalled, it is installed in the expected place. I changed the persmissions right now (chmod 777) but no change... I also changed ownership to www-data temporarily (chown www-data) but no change... (so I switched it back to root).

ls -la gives me now: -rwxrwxrwx 1 root root 286 Aug 16 18:25 occ

Seems like a broken base system in general where you might get better help when asking on a community dedicated to your used distro.

Thanks for your input. I did a test and created an own php file (just with phpinfo(); ) and this works fine (by running php phpinfo.php ). So my base system handles the php scripts correct or do I miss something?

It doesn't look like you're running the command in the same way. But i really think this is something for a linux / distro specific forums

You were right! Thanks a lot.
It was a kind of stupid error but I will make the confession... Since debian 8.1 or so the 'sudo' program isn't installed by default, installing this allowed me to execute the script as an other user (in this case, www-data). I ran the phpinfo.php script as the logged in user, so 'sudo' wasn't needed for this.

sudo -u www-data php occ upgrade