Gam Export

86 views
Skip to first unread message

Jeremy Fenelon

unread,
Jul 24, 2018, 11:19:52 AM7/24/18
to GAM for G Suite
I am creating some scripts to create daily reports of specific groups. Problem is when the file already exists the command fails due to duplicate file names.

Is there a switch in  python that would allow me to overwrite an existing file or a variable I can add to append the filename with a date?

Ross Scroggs

unread,
Jul 24, 2018, 1:37:40 PM7/24/18
to google-ap...@googlegroups.com
Jeremy,

Show me your command.

Ross


On Tue, Jul 24, 2018 at 8:19 AM Jeremy Fenelon <fene...@u4sd.org> wrote:
I am creating some scripts to create daily reports of specific groups. Problem is when the file already exists the command fails due to duplicate file names.

Is there a switch in  python that would allow me to overwrite an existing file or a variable I can add to append the filename with a date?

--
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 post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/a917b722-5a6d-4260-8917-9bbefe82be3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

+KimNilsson

unread,
Jul 25, 2018, 8:43:14 AM7/25/18
to GAM for G Suite
Like Ross is suggesting by asking you to provide your real command is that all depends on how you are pushing your info to said file.

I for example often use an app called tee with the option -a for append, but if you're just piping stdout to a file with >, then a simple >> would suffice to append. But, as you indicated, you wanted a date to tell you were new info is added. I know that's possible, but it's a bit trickier.

Just creating a dated file is a lot easier.
Here's an example where I regularly change settings of all groups.

/home/user/gamadv-x/gam print groups | /home/user/gamadv-x/gam csv - update group ~Email showInGroupDirectory true who_can_join invited_can_join who_can_view_membership all_in_domain_can_view who_can_view_group all_members_can_view who_can_leave_group none_can_leave include_in_global_address_list true | /usr/bin/tee -a /home/user/gam-activities/Fix.new.groups-$(date +'%F').txt

It's of course only the bit on the end that's relevant.

-$(date +'%F').txt

That will grab the current date from the shell and insert that as part of the filename at the end. You can format the date as you please. See man date for the syntax.
Reply all
Reply to author
Forward
0 new messages