GAMADV-XTD3: Showing/updating multiple courses with spaces in aliases? (Windows 10)

69 views
Skip to first unread message

Simon Stockhaus

unread,
Oct 3, 2019, 5:50:39 AM10/3/19
to GAM for G Suite
Hello,

I'm trying to show/manipulate several courses at once using gam courses, but I'm having troubles with aliases that contain spaces. I've tried doing it as the documentation suggests (enclosing the entire courses parameter in double quotes and then each course alias in single quotes), but it seems that either the shell (I've tried both CMD and PowerShell) or GAM parses the single quotes as part of the string instead of, well, quotes.

For example, running:
gam info courses "'d:17a Teknik','d:17b Teknik'"
results in:
Course: 'd:17a, Show Info Failed: Does not exist (1/4)
Course: Teknik', Show Info Failed: Does not exist (2/4)
Course: 'd:17b, Show Info Failed: Does not exist (3/4)
Course: Teknik', Show Info Failed: Does not exist (4/4)

Is this a bug in GAM, or is it a problem with CMD/Powershell, and, most importantly, is there a workaround?

Simon Stockhaus

unread,
Oct 3, 2019, 7:39:07 AM10/3/19
to GAM for G Suite
UPDATE: Tried doing the same thing on OS X, got the same result. Also tried using backslashes to prevent quotes from being stripped, but it didn't work either:

gam info courses \"\'d:19a Teknik\', \'d:19b Teknik\'\"


Command: /usr/local/gamadv-xtd3/gam info courses "'d:19a >>>"Teknik',"<<< 'd:19b Teknik'"




ERROR: Invalid argument


Is this somehow PEBKAC on my side, or is this a GAM issue?

Ross Scroggs

unread,
Oct 3, 2019, 9:38:50 AM10/3/19
to google-ap...@googlegroups.com
Fixed 4.95.01

-- 
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/91e3505e-77f6-4247-82a4-cb88ae1a3a1d%40googlegroups.com.

Simon Stockhaus

unread,
Oct 4, 2019, 4:51:53 AM10/4/19
to GAM for G Suite
Thanks a ton, seems to work in the OS X terminal now! I'll try it on Windows later.

However, if I try to call gam from a Bash script I still get a similar issue. Here's my script:

#!/bin/bash
shopt -s expand_aliases
source ~/.bash_profile

classList=(17a 17b 17c 17d 17e 17f 17g 18a 18b 18c 18d 18e 18f 19a 19b 19c 19d 19e 19f 19g)
subjectList=("Bild" "Biologi" "Engelska" "Fysik" "Geografi" "Historia" "Idrott och hälsa" "Kemi" "Matematik" "Moderna språk" "Musik" "Religionskunskap" "Samhällskunskap" "Slöjd" "Svenska" "Svenska som andraspråk" "Teknik")
declare courseList
declare subject
declare class

for class in "${classList[@]}"
do
  courseList=""
  for subject in "${subjectList[@]}"
  do
    courseList+="'d:${class} ${subject}',"
  done
  courseList="\"${courseList%","}\""
  gam courses ${courseList} sync students courseparticipants d:${class}
  printf "$class klar...\n"
  sleep 5
done

For example, for the first class, 17a, the script would run this line:

gam courses "'d:17a Bild','d:17a Biologi','d:17a Engelska','d:17a Fysik','d:17a Geografi','d:17a Historia','d:17a Idrott och hälsa','d:17a Kemi','d:17a Matematik','d:17a Moderna språk','d:17a Musik','d:17a Religionskunskap','d:17a Samhällskunskap','d:17a Slöjd','d:17a Svenska','d:17a Svenska som andraspråk','d:17a Teknik'" sync students courseparticipants d:17a


However when I run the script gam gives me this error:

Command: /usr/local/gamadv-xtd3/gam courses >>>"'d:17a<<< "Bild','d:17a" "Biologi','d:17a" "Engelska','d:17a" "Fysik','d:17a" "Geografi','d:17a" "Historia','d:17a" Idrott och "hälsa','d:17a" "Kemi','d:17a" "Matematik','d:17a" Moderna "språk','d:17a" "Musik','d:17a" "Religionskunskap','d:17a" "Samhällskunskap','d:17a" "Slöjd','d:17a" "Svenska','d:17a" Svenska som "andraspråk','d:17a" Teknik'" sync students courseparticipants d:17a


ERROR: No closing quotation

Help: Syntax in file /usr/local/gamadv-xtd3/GamCommands.txt

Help: Documentation is at https://github.com/taers232c/GAMADV-XTD3/wiki


If I change the script to print the gam command instead of running it and copy+paste it into the terminal it works fine:

simonstockhaus$ gam courses "'d:17a Bild','d:17a Biologi','d:17a Engelska','d:17a Fysik','d:17a Geografi','d:17a Historia','d:17a Idrott och hälsa','d:17a Kemi','d:17a Matematik','d:17a Moderna språk','d:17a Musik','d:17a Religionskunskap','d:17a Samhällskunskap','d:17a Slöjd','d:17a Svenska','d:17a Svenska som andraspråk','d:17a Teknik'" sync students courseparticipants d:17a

Getting all Students for 17a, may take some time on a large Course...


Is there some error in my script or is there an environment variable I need to change to get it to work?

Den torsdag 3 oktober 2019 kl. 15:38:50 UTC+2 skrev Ross Scroggs:
Fixed 4.95.01

On Oct 3, 2019, at 4:39 AM, Simon Stockhaus <simon.s...@edu-lustlara.se> wrote:

UPDATE: Tried doing the same thing on OS X, got the same result. Also tried using backslashes to prevent quotes from being stripped, but it didn't work either:

gam info courses \"\'d:19a Teknik\', \'d:19b Teknik\'\"


Command: /usr/local/gamadv-xtd3/gam info courses "'d:19a >>>"Teknik',"<<< 'd:19b Teknik'"




ERROR: Invalid argument


Is this somehow PEBKAC on my side, or is this a GAM issue?

-- 
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Ross Scroggs

unread,
Oct 4, 2019, 10:29:09 AM10/4/19
to google-ap...@googlegroups.com
Simon,

In the script you need to surround your variable with "".
  courseList="\"${courseList%","}\""
  gam courses ${courseList} sync students courseparticipants "d:${class}"

Ross


Fixed 4.95.01

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/b492a117-0a36-458b-94d0-d7813ddda5db%40googlegroups.com.


--

+KimNilsson

unread,
Oct 6, 2019, 4:43:07 PM10/6/19
to GAM for G Suite
Simon, kul med lite fler svenskar som gillar GAM. :-)

Neat script, though I never understood the fascination with syncing students to Classroom, since it's so darn easy for the teacher and students to manage it themselves.

Especially since a sync can really mess things up when students change classes. Not an uncommon thing at least in secondary school, even if perhaps not so common in primary school (where this looks to be).

Still, I can appreciate the neatness of syncing members from one course to another, or in your case to 17 others. :-)
However, that leaves you with an error for many of your students, as nobody takes both Svenska, and Svenska som andraspråk.
Reply all
Reply to author
Forward
0 new messages