X-Spam-Check-By: sourceware.org From: "Dave Korn" To: References: <46116207 DOT 8060009 AT cygwin DOT com> <5abc24640704021326p2bfbcc0che61f4aec02964ec1 AT mail DOT gmail DOT com> <46116C70 DOT 8030508 AT cygwin DOT com> <016001c775fd$c44d3b80$2e08a8c0 AT CAM DOT ARTIMI DOT COM> Subject: RE: Varibles not working in do loop... Date: Tue, 3 Apr 2007 16:12:17 +0100 Message-ID: <016701c77602$77f0a420$2e08a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 03 April 2007 15:46, Kevin Markle wrote: > Dave Korn pretended : >> What are you *trying* to do with that second grep? > There are 2 files related to each client listed in the file > 1group_1a_dev_clientlist.out the first grep grabs both files and the > second one get the specific log with the work windows in it: > > kmarkle AT backup /cygdrive/e/wsus/group_1a_DEV > $ ls -al > total 27992 > drwxrwxrwx+ 2 Administrators ???????? 0 Apr 2 16:51 . > drwx------+ 6 Administrators ???????? 0 Apr 3 10:41 .. > -rwx------+ 1 Administrators ???????? 1284874 Mar 29 01:19 > bvapp1_WINDOWSUpdate.log > -rwx------+ 1 Administrators ???????? 27394 Apr 3 10:03 > bvapp1_asr.log > > > DIR="cygdrive/e/wsus/group_1a_DEV" > > for t in `cat $DIR/1group_1a_dev_clientlist.out` > do > > echo $t > #LOG=`ls -al $FILE | grep $T | grep WINDOWS | gawk '{print $9}'` > #LOG=`ls -al cygdrive/e/wsus/group_1a_DEV | grep $t | grep WINDOWS | > gawk '{print $9}'` > LOG=`ls -al $DIR | grep $t | grep WINDOWS` > echo $t > echo The value of LOG is $LOG > UPDATES_NEEDED=`cat $LOG | grep "updates detected" | tail -1` > echo $UPDATES_NEEDED > > done So, what output do you see when you run it? I see /artimi/software/firmware $ ./script bvapp1_WINDOWSUpdate.log bvapp1_WINDOWSUpdate.log The value of LOG is -rw-r--r-- 1 dk Domain Users 0 Apr 3 15:54 bvapp1_WINDOWSUpd ate.log cat: invalid option -- r Try `cat --help' for more information. bvapp1_asr.log bvapp1_asr.log The value of LOG is ... and then it hangs, waiting for cat, as before. Note that you probably want to be using "ls -1", not "ls -l" (that's a digit one instead of letter l). What is actually in your 1group_1a_dev_clientlist.out file? Can you please double check it really does have the relevant filenames in it? Try adding some extra lines around where you set LOG: LOG1=`ls -al $DIR` echo LOG1 is ${LOG1} LOG2=`ls -al $DIR | grep $t` echo LOG2 is ${LOG2} LOG3=`ls -al $DIR | grep $t | grep WINDOWS` echo LOG3 is ${LOG3} ***PING! I bet you have dos line endings in your 1group_1a_dev_clientlist.out file. That means that in the lines: > for t in `cat $DIR/1group_1a_dev_clientlist.out` > do > > echo $t t is not equal to "bvapp1_WINDOWSUpdate.log", it is equal to "bvapp1_WINDOWSUpdate.log\r", which is not the name of the file! You should be able to fix this by either running d2u on the 1group_1a_dev_clientlist.out file, or you could replace the for loop in your script like so: for t in `cat $DIR/1group_1a_dev_clientlist.out | d2u` cheers, DaveK -- Can't think of a witty .sigline today.... -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/