taers232c / GAMADV-XTD3

Command line tool to manage Google Workspace
732 stars 86 forks source link

Error in Cron after upgrading GAMAdv #210

Closed angelocabrera closed 2 years ago

angelocabrera commented 3 years ago

I have a shell script which made calls to gam commands. This script has execution permissions and I can run it in the terminal without problems. I also have this script in my crontab (all with the same linux user) and it was running ok, but after an upgrade that I did to GAMAdv, the cron fails giving me permissions errors.

For instance, if I run my script to send a chat message it works: user@procesos-cron:~$ /home/user/gam_batch.sh test OPCION: test Chat Space: spaces/xxx, Chat Thread: spaces/xxx/threads/ULQi2tTA8q0, Chat Message: spaces/xxx/messages/ULQi2tTA8q0.ULQi2tTA8q0, Created

But when the same command runs in cron, I get this error:

Chat Space: spaces/xxx, Create Failed: The caller does not have permission

Does anyone knows how to fix this?

The same user that I use to run it from the terminal is the same in the cron, and I also check that both the script and the GAM command have execution permissions. I also use full paths in the script.

taers232c commented 3 years ago

In the shell do: env Is there a line like this? Your details will vary.

GAMCFGDIR=/home/user/.gam

In gam_batch.sh add the following line with value from line above.

export GAMCFGDIR="/home/user/.gam"

How do you specify the GAM executable in gam_batch.sh?

Ross

On Wed, Oct 13, 2021 at 8:12 AM angelocabrera @.***> wrote:

I have a shell script which made calls to gam commands. This script has execution permissions and I can run it in the terminal without problems. I also have this script in my crontab (all with the same linux user) and it was running ok, but after an upgrade that I did to GAMAdv, the cron fails giving me permissions errors.

For instance, if I run my script to send a chat message it works: @.***:~$ /home/user/gam_batch.sh test OPCION: test Chat Space: spaces/xxx, Chat Thread: spaces/xxx/threads/ULQi2tTA8q0, Chat Message: spaces/xxx/messages/ULQi2tTA8q0.ULQi2tTA8q0, Created

But when the same command runs in cron, I get this error:

Chat Space: spaces/xxx, Create Failed: The caller does not have permission

Does anyone knows how to fix this?

The same user that I use to run it from the terminal is the same in the cron, and I also check that both the script and the GAM command have execution permissions. I also use full paths in the script.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/210, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYLZJ4BLTZLA3IGEQ5Y3UGWOXFANCNFSM5F5OLQUQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Ross Scroggs @.***

angelocabrera commented 3 years ago

This fixed it!

export GAMCFGDIR="/home/user/.gam"

Thank you very much!!