This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Varibles not working in do loop...


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@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!  <lightbulb noise>

  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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]