![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Nested loop not running using cronjob | bihani4u | Shell Programming and Scripting | 9 | 09-26-2007 12:19 PM |
| Variable in While Loop Nested If | geass | Shell Programming and Scripting | 6 | 03-26-2007 07:09 PM |
| Nested while read line loop | Rakker | Shell Programming and Scripting | 7 | 06-24-2005 08:42 AM |
| nested loop | chinog | Shell Programming and Scripting | 5 | 04-20-2005 11:45 AM |
| nested read | TioTony | Shell Programming and Scripting | 2 | 03-05-2004 03:11 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
while read loop w/ a nested if statement - doesn't treat each entry individually
Hi -
Trying to take a list of ldap suffixes in a file, run an ldapsearch command on them, then run a grep command to see if it's a match, if not, then flag that and send an email alert. The list file (ldaplist) would look like - *********** o=company a o=company b *********** ** Note there are spaces in that file that need to be preserved. I was trying to use a for loop and someone suggested a while read loop in order to prevent the space from being treated as a line break. The problem w/ the script i created below is that it runs and only sends one email w/ the info from both entries in ldaplist. It's like my nested 'if' loop is not the right loop to use. I made it so that both entries should have 0 return codes and no luck. Runs once and that's it. Any suggestions to a better structure to this? I would try to use a for i in cat /ldaplist - do .... - but that fails because it doesn't treat the space in the ldaplist (ie: o=company a) as a space - even with " ". while read i do ldapsearch -h server1 -b "$i" objectclass=* ibm-replicationState |grep ibm-replicationState=ready > /dev/null 2>&1 if [ $? -ne 0 ]; then mailx -s "LDAP sync alert on `hostname`" u@mail.com 2>&1 fi done <ldaplist Thanks! |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|