BGP Detection script

Hello Folks.

I am not a script coder and it’s why i am asking here for some help on my request.
So… I have this:
GRE Tunnel to a provider A.
ETH Connection to a provider B.
BGP Session with provider A.
BGP Session with provider B with “Set BGP Communities” to “no advertise”.

I want a script that can remove the “no advertise” from provider B when the GRE tunnel falls. And put it back when the GRE tunnel come up again. (or when the BGP session from the provider A falls).

I ask this because my provider B doesn’t have communities and when that connection is up, all traffic comes over it. I want the provider B be the backup only.

Regards