scripting doubts

Arthur Meeks Meeks arthur.meeks.luppu at gmail.com
Fri Aug 7 08:59:52 UTC 2009


2009/8/6 Cameron Simpson <cs at zip.com.au>

> On 05Aug2009 09:52, Arthur Meeks Meeks <arthur.meeks.luppu at gmail.com>
> wrote:
> | 2009/8/5 Cameron Simpson <cs at zip.com.au>
> | > On 04Aug2009 20:04, Arthur Meeks Meeks <arthur.meeks.luppu at gmail.com>
> | > 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20090807/c5ac7a98/attachment-0001.html 


More information about the users mailing list