Re: scripting doubts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





2009/8/6 Cameron Simpson <cs@xxxxxxxxxx>
On 05Aug2009 09:52, Arthur Meeks Meeks <arthur.meeks.luppu@xxxxxxxxx> wrote:
| 2009/8/5 Cameron Simpson <cs@xxxxxxxxxx>
| > On 04Aug2009 20:04, Arthur Meeks Meeks <arthur.meeks.luppu@xxxxxxxxx>
| > wrote:
| > | What's the problem? When I can't log into a mysql database (mostly
| > | cause it is down) I got a "0", what I want is to discard these
| > | machines, so they're not included in /tmp/whatever.
| >
| > You're probably not getting to pay attention to the mysql exit status.
[...]
| >    mysql -h "$host" -ublah -pfhfhfhfhf -e "show grants..." >"$grants" \
| >    || { echo "skipping $host, maybe down" >&2
| >         continue
| >       }
| >    egrep ......... <"$grants" | wc -l ...
|
| Hi Cameron,
| First off, thanks a lot.
| I've been trying to include those lines in my script without modifying it
| too much but it wasn't possible.
| How would you include your piece of code to this script:
|
| #!/bin/bash
| PASS="fff"
| LIST="/tmp/perms"
|
| for i in `cat /opt/lists/*clusters`; do echo -n $i: && mysql -h$i -uroot
| -p$PASS -e"show grants for 'user'@'10.10.%.%';" | egrep "REPLICATION
| CLIENT|ALL" | wc -l ; done > $LIST

Like this (untested):

for i in `cat /opt/lists/*clusters`
do
 mysql "-h$i" -uroot "-p$PASS" -e"show grants for 'user'@'10.10.%.%';" >mysql.out || continue
 echo -n $i:; egrep "REPLICATION CLIENT|ALL" <mysql.out | wc -l
done >"$LIST"

Seems to work like a charm!
Thanks a lot Cameron!

A

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux