UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 1st, 2006, 03:36 AM
amitmhetre amitmhetre is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 30 amitmhetre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 4 m 28 sec
Reputation Power: 0
Angry Using word count in file for comparison.

The script i am using is as follows:
CONT="TRUE"
echo "Waiting to Get Scheduled"
while [ "$CONT" = "TRUE" ]
do
if [ ! -f $DSSDATW5/W5DW_RUNNING.out ]
then
break
else
if ["`wc -l $DSSDATW5/W5DW_RUNNING.out | cut -c1-8`" -eq 0 ]
then break
else sleep 100
continue
fi
fi
done

first part look if file exists, if yes then checks for word count.
But when it checks for word count
it gives me error at line of comparison with word count

DEL_FILE_W5DW_DENORM_FINAL[22]: [ 2: not found.

where DEL_FILE_W5DW_DENORM_FINAL is the job name where the code exists.
can any one help to understand whats going wrong.

Reply With Quote
  #2  
Old August 1st, 2006, 05:46 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 712 SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 22 h 13 m 34 sec
Reputation Power: 315
Ack .. nasty, nasty, nasty!!!!

Code:
["`wc -l $DSSDATW5/W5DW_RUNNING.out | cut -c1-8`" -eq 0 ]


First off, that is comparing a string (you have enclosed the wc command in quotes) to a numeric (the 0) with the numeric equality testing operand (the -eq) and you are also extracting the first 8 characters of the returned result from the wc, which is not what you want.

What you want is:

Code:
[`wc -l $DSSDATW5/W5DW_RUNNING.out | awk '{print $1}'` -eq 0 ]


which will, I hope!, do a wc and then just pass on to the test the first field which should be the count.

And I am assuming that the variable $DSSDATW5 is defined elsewhere?

Reply With Quote
  #3  
Old August 1st, 2006, 08:43 AM
amitmhetre amitmhetre is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 30 amitmhetre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 4 m 28 sec
Reputation Power: 0
Thumbs up cool dude

The solution that you have given worked , with one more change that was specific to my logic.
if [`wc -w $DSSDATW5/W5DW_RUNNING.out | awk '{print $1}'` -eq 0 ]

and even this works fine.
[`wc -w $DSSDATW5/W5DW_RUNNING.out | cut -c0-8` -eq 0 ]
Even this can be a solution.

Thanks SimonJM

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Using word count in file for comparison.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway