Moosh - does it work?

Moosh - does it work?

by Diane Soini -
Number of replies: 11

Installed Moosh. I can do some commands and others fail. Examples of commands that fail:

moosh user-list --course=12969
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 83 bytes) in [install]/lib/dml/mysqli_native_moodle_database.php on line 1084


moosh course-enrolleduser 12969
moosh version 0.23
No command provided, possible commands:
...


moosh course-list test
!!! Error reading from database !!!


I'm running moosh as the webserver user and I have had to set the home directory to the dataroot directory since that's the only place where the webserver user can write to. None of the webserver's files are owned by the webserver user. I have similar problems trying to run this as the root user. So I'm not sure if my problems are because of permissions problems or because maybe Moosh doesn't really work, or their documentation on moosh-online.com is out of date. Any help?

Average of ratings: -
In reply to Diane Soini

Re: Moosh - does it work?

by Tomasz Muras -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators

Hi,


Each moosh command is coded separately - how well it works across different Moodle versions - it varies. I need to know what version of Moodle are you using. The easiest for me would be if you raise an issue on github

In case of output like:

moosh course-list test
!!! Error reading from database !!!

turn the debug on first (e.g. in config.php), so you can capture the exact error and stack trace.

cheers,
Tomek

Average of ratings: Useful (3)
In reply to Tomasz Muras

Re: Moosh - does it work?

by Diane Soini -

We've got it installed on a system with a moodle 2.8 and 3.1 installation running.

The permissions are really weird. I have to run it as apache, but the apache user has no home directory, so I set HOME to the dataroot. Other than that, it seems that the documentation on commands is out-dated or something else isn't set up correctly. And why would it run out of memory listing users for a course with less than 10 users?

In reply to Diane Soini

Re: Moosh - does it work?

by Tomasz Muras -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators

Hi Diane,

The permissions are really weird. I have to run it as apache, but the apache user has no home directory, so I set HOME to the dataroot.

The permissions are pretty important, seems like a good entry for FAQ - http://moosh-online.com/faq/#permissions .


it seems that the documentation on commands is out-dated or something else isn't set up correctly.

The documentation should be up to date but I keep http://moosh-online.com/commands/ up to date only for the latest version of the command - so it may happen that there is a difference between version for Moodle 2.8 and 3.1.

It's very easy to edit the documentation - for example http://moosh-online.com/commands page is generated from https://github.com/tmuras/moosh/blob/master/www/commands/index.md . If you have any documentation improvements, please send them to me as pull request on github.


Why would it run out of memory listing users for a course with less than 10 users?

It should not. If you can provide more information and report an issue, so I can reproduce the problem - I may be able to fix it.


cheers,
Tomek

In reply to Tomasz Muras

Re: Moosh - does it work?

by Diane Soini -
I turned on debug. It would appear that perhaps the documentation is incorrect about how to run this command. Here's the crazy output:


moosh course-list test
!!! Error reading from database !!!
!! Unknown column 'test' in 'where clause'
SELECT c.id,c.category,c.shortname,c.fullname,c.visible FROM mdl_course c WHERE c.category IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) AND (test)
[array (
0 => 0,
1 => 691,
2 => 704,
3 => 709,
4 => 695,
5 => 736,
6 => 714,
7 => 708,
8 => 735,
9 => 734,
10 => 725,
11 => 726,
12 => 707,
13 => 729,
14 => 723,
15 => 705,
16 => 717,
17 => 730,
18 => 696,
19 => 738,
20 => 715,
21 => 721,
22 => 703,
23 => 710,
24 => 694,
25 => 706,
26 => 713,
27 => 702,
28 => 732,
29 => 700,
30 => 724,
31 => 727,
32 => 699,
33 => 718,
34 => 722,
35 => 733,
36 => 716,
37 => 712,
38 => 711,
39 => 720,
40 => 701,
41 => 697,
42 => 731,
43 => 698,
44 => 737,
45 => 692,
46 => 693,
47 => 774,
48 => 629,
49 => 659,
50 => 685,
51 => 633,
52 => 673,
53 => 670,
54 => 676,
55 => 680,
56 => 658,
57 => 648,
58 => 667,
59 => 640,
60 => 660,
61 => 681,
62 => 665,
63 => 664,
64 => 656,
65 => 631,
66 => 666,
67 => 638,
68 => 639,
69 => 662,
70 => 654,
71 => 637,
72 => 651,
73 => 646,
74 => 655,
75 => 657,
76 => 663,
77 => 668,
78 => 644,
79 => 641,
80 => 678,
81 => 634,
82 => 632,
83 => 686,
84 => 636,
85 => 683,
86 => 682,
87 => 645,
88 => 671,
89 => 679,
90 => 630,
91 => 669,
92 => 675,
93 => 661,
94 => 672,
95 => 652,
96 => 649,
97 => 647,
98 => 653,
99 => 642,
100 => 643,
101 => 635,
102 => 650,
103 => 739,
104 => 772,
105 => 788,
106 => 792,
107 => 784,
108 => 791,
109 => 797,
110 => 757,
111 => 744,
112 => 795,
113 => 764,
114 => 789,
115 => 758,
116 => 762,
117 => 754,
118 => 750,
119 => 743,
120 => 745,
121 => 776,
122 => 740,
123 => 756,
124 => 790,
125 => 741,
126 => 755,
127 => 767,
128 => 770,
129 => 781,
130 => 771,
131 => 777,
132 => 749,
133 => 761,
134 => 742,
135 => 746,
136 => 766,
137 => 759,
138 => 793,
139 => 778,
140 => 798,
141 => 794,
142 => 751,
143 => 780,
144 => 773,
145 => 787,
146 => 747,
147 => 775,
148 => 769,
149 => 760,
150 => 748,
151 => 768,
152 => 782,
153 => 779,
154 => 765,
155 => 753,
156 => 752,
157 => 799,
158 => 568,
159 => 620,
160 => 621,
161 => 583,
162 => 578,
163 => 617,
164 => 614,
165 => 592,
166 => 619,
167 => 612,
168 => 595,
169 => 588,
170 => 622,
171 => 587,
172 => 593,
173 => 571,
174 => 584,
175 => 600,
176 => 608,
177 => 572,
178 => 624,
179 => 598,
180 => 602,
181 => 589,
182 => 618,
183 => 611,
184 => 594,
185 => 603,
186 => 609,
187 => 599,
188 => 573,
189 => 575,
190 => 607,
191 => 582,
192 => 613,
193 => 623,
194 => 569,
195 => 586,
196 => 570,
197 => 605,
198 => 615,
199 => 574,
200 => 616,
201 => 596,
202 => 591,
203 => 585,
204 => 590,
205 => 577,
206 => 576,
207 => 606,
208 => 579,
209 => 625,
210 => 626,
211 => 627,
212 => 628,
213 => 185,
214 => 9,
215 => 110,
216 => 549,
217 => 677,
218 => 40,
219 => 52,
220 => 456,
221 => 597,
222 => 728,
223 => 564,
224 => 53,
225 => 50,
226 => 83,
227 => 327,
228 => 394,
229 => 457,
230 => 485,
231 => 552,
232 => 580,
233 => 581,
234 => 689,
235 => 690,
236 => 786,
237 => 43,
238 => 80,
239 => 94,
240 => 610,
241 => 39,
242 => 340,
243 => 342,
244 => 344,
245 => 688,
246 => 72,
247 => 54,
248 => 51,
249 => 93,
250 => 113,
251 => 347,
252 => 73,
253 => 601,
254 => 14,
255 => 308,
256 => 544,
257 => 763,
258 => 282,
259 => 283,
260 => 604,
261 => 16,
262 => 719,
263 => 783,
264 => 1,
265 => 15,
266 => 123,
267 => 144,
268 => 184,
269 => 348,
270 => 349,
271 => 350,
272 => 351,
273 => 352,
274 => 353,
275 => 354,
276 => 355,
277 => 356,
278 => 357,
279 => 358,
280 => 359,
281 => 360,
282 => 361,
283 => 362,
284 => 363,
285 => 364,
286 => 365,
287 => 366,
288 => 367,
289 => 368,
290 => 369,
291 => 370,
292 => 371,
293 => 372,
294 => 373,
295 => 374,
296 => 375,
297 => 376,
298 => 377,
299 => 378,
300 => 379,
301 => 383,
302 => 384,
303 => 385,
304 => 386,
305 => 387,
306 => 388,
307 => 389,
308 => 390,
309 => 391,
310 => 392,
311 => 393,
312 => 395,
313 => 396,
314 => 397,
315 => 398,
316 => 399,
317 => 400,
318 => 401,
319 => 402,
320 => 403,
321 => 404,
322 => 405,
323 => 406,
324 => 407,
325 => 408,
326 => 409,
327 => 410,
328 => 411,
329 => 412,
330 => 413,
331 => 414,
332 => 415,
333 => 416,
334 => 417,
335 => 418,
336 => 419,
337 => 420,
338 => 421,
339 => 422,
340 => 423,
341 => 424,
342 => 425,
343 => 426,
344 => 427,
345 => 428,
346 => 429,
347 => 430,
348 => 431,
349 => 432,
350 => 433,
351 => 434,
352 => 435,
353 => 436,
354 => 437,
355 => 438,
356 => 439,
357 => 440,
358 => 441,
359 => 442,
360 => 443,
361 => 444,
362 => 445,
363 => 446,
364 => 447,
365 => 448,
366 => 449,
367 => 450,
368 => 451,
369 => 452,
370 => 453,
371 => 454,
372 => 455,
373 => 458,
374 => 459,
375 => 460,
376 => 461,
377 => 462,
378 => 463,
379 => 464,
380 => 465,
381 => 466,
382 => 467,
383 => 468,
384 => 469,
385 => 470,
386 => 471,
387 => 472,
388 => 473,
389 => 474,
390 => 475,
391 => 476,
392 => 477,
393 => 478,
394 => 479,
395 => 480,
396 => 481,
397 => 482,
398 => 483,
399 => 484,
400 => 486,
401 => 487,
402 => 488,
403 => 489,
404 => 490,
405 => 491,
406 => 492,
407 => 493,
408 => 494,
409 => 495,
410 => 496,
411 => 497,
412 => 498,
413 => 499,
414 => 500,
415 => 501,
416 => 502,
417 => 503,
418 => 505,
419 => 506,
420 => 507,
421 => 508,
422 => 541,
423 => 509,
424 => 510,
425 => 563,
426 => 529,
427 => 567,
428 => 539,
429 => 565,
430 => 546,
431 => 554,
432 => 566,
433 => 545,
434 => 548,
435 => 522,
436 => 561,
437 => 547,
438 => 538,
439 => 516,
440 => 512,
441 => 515,
442 => 527,
443 => 514,
444 => 556,
445 => 555,
446 => 526,
447 => 534,
448 => 533,
449 => 558,
450 => 559,
451 => 520,
452 => 513,
453 => 518,
454 => 528,
455 => 553,
456 => 532,
457 => 540,
458 => 562,
459 => 550,
460 => 557,
461 => 551,
462 => 535,
463 => 542,
464 => 530,
465 => 560,
466 => 537,
467 => 536,
468 => 524,
469 => 511,
470 => 519,
471 => 523,
472 => 517,
473 => 543,
474 => 531,
475 => 525,
476 => 521,
477 => 157,
478 => 315,
479 => 291,
480 => 296,
481 => 343,
482 => 337,
483 => 330,
484 => 338,
485 => 304,
486 => 339,
487 => 341,
488 => 298,
489 => 290,
490 => 322,
491 => 297,
492 => 303,
493 => 306,
494 => 312,
495 => 324,
496 => 292,
497 => 288,
498 => 293,
499 => 334,
500 => 300,
501 => 316,
502 => 318,
503 => 336,
504 => 321,
505 => 320,
506 => 326,
507 => 323,
508 => 299,
509 => 328,
510 => 317,
511 => 295,
512 => 345,
513 => 314,
514 => 346,
515 => 329,
516 => 311,
517 => 313,
518 => 287,
519 => 307,
520 => 335,
521 => 333,
522 => 309,
523 => 319,
524 => 305,
525 => 289,
526 => 302,
527 => 301,
528 => 325,
529 => 310,
530 => 294,
)]
Error code: dmlreadexception !!
!! Stack trace: * line 474 of /lib/dml/moodle_database.php: dml_read_exception thrown
* line 1088 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
* line 79 of /home/support/Git/moosh/Moosh/Command/Moodle26/Course/CourseList.php: call to mysqli_native_moodle_database->get_records_sql()
* line 281 of /home/support/Git/moosh/moosh.php: call to Moosh\Command\Moodle26\Course\CourseList->execute()
!!
In reply to Diane Soini

Re: Moosh - does it work?

by Tomasz Muras -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators

Yes, http://moosh-online.com/commands/#course-list refers to an old version of the command and should be updated.

The search argument is really a part of the SQL you should provide to find the courses you're looking for. It will be injected after WHERE clause. For example to find all with "test" inside fullname you write:

moosh course-list 'fullname like "%test%"'


vagrant@vagrant:/var/www/html/moodle$ moosh course-list --help
*** course-list ***
OPTIONS:
	-h, --help
		help information

	-n, --idnumber
		show idnumber

	-i, --id
		display id only column

	-c, --categorysearch=
		courses from given category id only

	-v, --visible=
		show all/yes/no visible

	-e, --empty=
		show only empty courses: all/yes/no

	-f, --fields=
		show only those fields in the output (comma separated)

	-o, --output=
		output format: tab, csv


ARGUMENTS:
	search ...
In reply to Diane Soini

Re: Moosh - does it work?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I have used it for several different things and it seems to work very well.

In reply to Marcus Green

Re: Moosh - does it work?

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Confirming, Moosh works like a treat.

A big thank you to Tomasz for this tool.

In reply to Nicolas Martignoni

Re: Moosh - does it work?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Excellent, I have used it successfully for scripting multi gigabyte backup and restore of courses.

In reply to Marcus Green

Re: Moosh - does it work?

by Diane Soini -

Have you been able to run all the commands? Are you able to run this one?

moosh user-list --course=12969

I want to figure out how to set it up and use it correctly. I want to make a case to our group to use this.