How to catch errors from GAM 4.21?

39 views
Skip to first unread message

Nicoalejo

unread,
Apr 25, 2017, 2:38:15 AM4/25/17
to GAM for G Suite
I have some scripts that use GAM for updating, creating and eliminating users, and I want to catch if there's some error in any of those process. The ideal would be a way to save those directly to a database but if I could catch them in any kind of text file it'll be enough.

Samuel

unread,
Apr 27, 2017, 1:45:44 AM4/27/17
to GAM for G Suite

Hello,

I can't give you my code, in my case

1. I check the exit code

$ ./gam.py info domain
<some result>
$ echo $
?
0

$ ./gam.py info dom
ERROR
: dom is not a valid argument for "gam info"
$ echo $
?
2

2. if the exit code !=0 or the result contains "ERROR"
You can sometimes have an exit code of 0 and an ERROR message

$ ./gam.py update group <existing group> add member user <already member email>
 adding member
<already member email>...
ERROR
: 409: Member already exists. - duplicate
$ echo $
?
0


Reply all
Reply to author
Forward
0 new messages