0

I've written a script to get the size of my S3 storage, the script works fine barring the fact that it keeps looping and never ends. I get all the outputs as I need but it keeps going through them.

Any ideas on why its looping?

#!/bin/sh
DAY=$(date +"%d%b%Y")
BUCKET='/home/user/Scripts/Holding/s3buckets.txt'
BLIST='/home/user/Scripts/Holding/blist.txt'
LOGDIR='/home/user/Scripts/Holding/'
USAGE=$BLIST
s3cmd ls > $BUCKET
awk '{print $3}' $BUCKET > $BLIST 
while read USAGE; do
s3cmd du -H $USAGE
done < $BUCKET > $LOGDIR/S3Usage$DAY.txt
mouviciel
  • 66,855
  • 13
  • 106
  • 140
Grimlockz
  • 2,541
  • 7
  • 31
  • 38

1 Answers1

0

Change s3cmd du -H $USAGE to s3cmd du -H s3://$USAGE

Without the s3://, s3cmd defaults to giving the listing for all buckets. I'm betting that s3buckets.txt just has the bucket names, not the protocol prefix.

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
  • the s3bucklist.txt is the list of s3 and then the blist.txt cuts them into a list of the correct prefix so not sure if that is the reason – Grimlockz Dec 07 '11 at 11:45
  • Ah, that makes sense. The problem is that you're doing all that to prep `$BLIST` but then ignoring it and reading from `$BUCKET`. – blahdiblah Dec 07 '11 at 17:08