<br><br><div class="gmail_quote">2009/8/6 Cameron Simpson <span dir="ltr"><<a href="mailto:cs@zip.com.au">cs@zip.com.au</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On 05Aug2009 09:52, Arthur Meeks Meeks <<a href="mailto:arthur.meeks.luppu@gmail.com">arthur.meeks.luppu@gmail.com</a>> wrote:<br>
| 2009/8/5 Cameron Simpson <<a href="mailto:cs@zip.com.au">cs@zip.com.au</a>><br>
| > On 04Aug2009 20:04, Arthur Meeks Meeks <<a href="mailto:arthur.meeks.luppu@gmail.com">arthur.meeks.luppu@gmail.com</a>><br>
| > wrote:<br>
</div><div class="im">| > | What's the problem? When I can't log into a mysql database (mostly<br>
| > | cause it is down) I got a "0", what I want is to discard these<br>
| > | machines, so they're not included in /tmp/whatever.<br>
| ><br>
</div><div class="im">| > You're probably not getting to pay attention to the mysql exit status.<br>
</div>[...]<br>
<div class="im">| >    mysql -h "$host" -ublah -pfhfhfhfhf -e "show grants..." >"$grants" \<br>
| >    || { echo "skipping $host, maybe down" >&2<br>
| >         continue<br>
| >       }<br>
| >    egrep ......... <"$grants" | wc -l ...<br>
|<br>
</div><div class="im">| Hi Cameron,<br>
| First off, thanks a lot.<br>
| I've been trying to include those lines in my script without modifying it<br>
| too much but it wasn't possible.<br>
| How would you include your piece of code to this script:<br>
|<br>
| #!/bin/bash<br>
| PASS="fff"<br>
| LIST="/tmp/perms"<br>
|<br>
| for i in `cat /opt/lists/*clusters`; do echo -n $i: && mysql -h$i -uroot<br>
| -p$PASS -e"show grants for 'user'@'10.10.%.%';" | egrep "REPLICATION<br>
| CLIENT|ALL" | wc -l ; done > $LIST<br>
<br>
</div>Like this (untested):<br>
<div class="im"><br>
for i in `cat /opt/lists/*clusters`<br>
do<br>
</div>  mysql "-h$i" -uroot "-p$PASS" -e"show grants for 'user'@'10.10.%.%';" >mysql.out || continue<br>
  echo -n $i:; egrep "REPLICATION CLIENT|ALL" <mysql.out | wc -l<br>
done >"$LIST"</blockquote><div><br>Seems to work like a charm!<br>Thanks a lot Cameron!<br><br>A <br></div></div><br>