Occ user::add does not recognize the argument list

Hi! I’m new to nextcloud and i’m trying to play with it. I’m trying to add an user with occ command doing something like:

export OC_PASS="${PASS}"

cd /var/www/html/nextcloud
sudo --preserve-env -u apache /usr/bin/php ./occ -vvv user:add  --password-from-env --email "${EMAIL}" --display-name "${args[@]}" -- "${USERNAME}"

but i keep getting this error:

In ArgvInput.php line 196:
                                                                       
  [Symfony\Component\Console\Exception\RuntimeException]               
  Too many arguments to "user:add" command, expected arguments "uid".  
                                                                       

Exception trace:
  at /var/www/html/nextcloud/3rdparty/symfony/console/Input/ArgvInput.php:196
 Symfony\Component\Console\Input\ArgvInput->parseArgument() at /var/www/html/nextcloud/3rdparty/symfony/console/Input/ArgvInput.php:89
 Symfony\Component\Console\Input\ArgvInput->parseToken() at /var/www/html/nextcloud/3rdparty/symfony/console/Input/ArgvInput.php:74
 Symfony\Component\Console\Input\ArgvInput->parse() at /var/www/html/nextcloud/3rdparty/symfony/console/Input/Input.php:56
 Symfony\Component\Console\Input\Input->bind() at /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php:285
 Symfony\Component\Console\Command\Command->run() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:1078
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:324
 Symfony\Component\Console\Application->doRun() at /var/www/html/nextcloud/3rdparty/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /var/www/html/nextcloud/lib/private/Console/Application.php:183
 OC\Console\Application->run() at /var/www/html/nextcloud/console.php:87
 require_once() at /var/www/html/nextcloud/occ:11

user:add [--password-from-env] [--generate-password] [--display-name [DISPLAY-NAME]] [-g|--group [GROUP]] [--email EMAIL] [--] <uid>

I really have no idea what is missing, as for my untrained eyes i respect exactly the required arguments…
Thanks a lot

Pretty certain this is a shell expansion issue or similar, rather than occ itself.

Hard to say without looking closer.

Doesn’t appear you provided a full reproducer.

I presume those other variables are provided values somewhere and there is also a parameter passed as an argument.

Also not sure what shell you’re testing in.

1 Like

Hi! So, this was bash, but anyway i found the problem : the Display Name does not support spaces, so doing:

--display-name "First_Name Last_Name"

was not accepted … i replaced the space with _ and this was solved.

I’m curious why for a Display Name (so something only used to be displayed) the spaces are not accepted …
Anyway, problem is solved.
Thanks!
Adrian

Can’t reproduce that issue:

# occ user:add --display-name "Test Test" test
Enter password: 
Confirm password: 
The account "test" was created successfully
Display name set to "Test Test"

weird … i will get back to this and try again … well, the fact is when i replaced the space with _ in display-name, the command worked … for the moment is good enough…

Are you quoting the value provided on the command line to your script?

Yes, in my first post i put the exact line from my script of user creation:

export OC_PASS="${PASS}"

cd /var/www/html/nextcloud
sudo --preserve-env -u apache /usr/bin/php ./occ -vvv user:add  --password-from-env --email "${EMAIL}" --display-name "${args[@]}" -- "${USERNAME}"

where args are in fact a copy of ${@}
the way that i use the script is:

run_occ_user_create FirstName LastName

Not in the script. The parameter you’re providing to the script - i.e.

run_occ_user_create 'FirstName LastName'

Right, i was not using quotes and my problem was from wrongly thinking that "${args[@]}" is quoted …
after i did DISPLAY_NAME=("${args[*]}") i can use --display-name "${DISPLAY_NAME}"

2 Likes

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.