scripting doubts

Arthur Meeks Meeks arthur.meeks.luppu at gmail.com
Tue Aug 4 11:53:30 UTC 2009


Hi guys,

I'm trying to create an script to verify some databases and their
privileges.

I have all of them in some files with the following format:
server1
server2
server3
server4

Being all of them MySQL servers and the first one the master and the rest of
the just the slaves.

I only want to check the privileges in the slaves and I've created the
following statement:
for i in `cat file1_cluster`; do echo -n $i: && mysql -h$i -uroot -pwhatever
-e"show grants for 'user'@'10.10.%.%';" | grep -i "REPLICATION CLIENT" | wc
-l ; done > /tmp/privs

Keep in mind I just want to know the slaves which doesn't have the
REPLICATION CLIENT privileges, just that.
So that will write in /tmp/privs something like:
server1:0
server2:1
server3:0

Being the value 0 a machine which doesn't have REPLICATION CLIENT privilege
and 1 being the value which mean it does.

The thing is, how can I do the "for" loop to avoid reading the first line of
the file: file1_cluster, file2_cluster etc...cause the master will never
have replication client privileges.

After reading the /tmp/privs with another for, I will use cut -d ":" -f to
look for values distinct from 0 and do a mail -s to the admins.

Any help will be more than appreciated.

Thanks a lot
A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20090804/91fa4c0a/attachment-0001.htm>


More information about the fedora-list mailing list