Does it run on Windows?

To quote Marcus:

...installed Moosh under Win32 and it seems to work OK. I have cleared cache, added a user and generated a form. It will fall over on unixy things like your example of

moosh user-create user_{1..5}


moosh user-create_user_1

works fine.

At the same time several commands will not work.

At the moment I do not have enough time to support moosh on Windows - but patches that fix Windows-specific issues are welcome.

Also see installation instructions from Michael and if you really need to run it on Windows, I suggest Cygwin.

As which user should moosh be run? What's the story with permission's check?

The permissions are very important and incorrect use of them may break your Moodle installation.

Imagine that you have Moodle running by apache server, as user www-data. Now, you run moosh from commandline as user root. Since most of the moosh commands use Moodle API and include Moodle libraries, there is a good chance that executing them will create new files in your data directory (e.g. in moodledata/cache).

If that happens, you end up with moodledata files that can not be deleted by your Moodle installation (www-data user). This may lead to very unexpected behaviour - trust me, I learned it the hard way.

To help you not to break your Moodle, there is a check at the beginning that may give you a message:

One of your Moodle data directories ({$moodledata_owner['dir']}) is owned by
different user ({$moodledata_owner['user']['name']}) than the one that runs the script ({$shell_user['name']}).
If you're sure you know what you're doing, run moosh with -n flag to skip that test.

If you want to ignore that warning, just run moosh with -n flag:

  moosh -n ...

But in most of the cases, you should run moosh as the same user as the owner of your web server. For example:

sudo -u www-data moosh ...

Moodle development book: