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" i.e. do the mysql command ad save the output. If the mysql command failed (host down, for example), don't bother with the second half of the loop. Cheers, -- Cameron Simpson <cs@xxxxxxxxxx> DoD#743 http://www.cskk.ezoshosting.com/cs/ C makes it easy for you to shoot yourself in the foot. C++ makes that harder, but when you do, it blows away your whole leg. - Bjarne Stroustrup -- fedora-list mailing list fedora-list@xxxxxxxxxx To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines