Re: stupid shell tricks again

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Craig White
Date:  
To: plug-discuss
Subject: Re: stupid shell tricks again
On Mon, 2004-03-22 at 15:13, Jeremy C. Reed wrote:
> On Mon, 22 Mar 2004, Craig White wrote:
>
> > I'm now up to ...
> > for i in `cut -f1 $wdirect/users-homes`; do result=$(( $size_plateau -
> > $i )); if (($result<=0)); then `echo $i`; fi; done
> >
> > so it's time to use the grep thought that Jeremy had
>
> I'd do something like:
>
> du -sh /home/* | while read line ; do
>  i=`echo $line | cut -f1` ;
>  if [ $i -gt $size_plateau ] ; then
>    echo $i for `echo $line | cut -f2 | xargs -n 1 basename`
>  fi
> done

>
> (not tested)

---
I will test it - I am feeling comfortable with this (before I saw your
email)...

#!/bin/sh
wfile1=/root/scripts/users-homes
wfile2=/root/scripts/profiles-exceed-limits
chdirect=/home/filesystems/samba/profiles
size_plateau=153600
du -s $chdirect/* > $wdirect/users-homes
> $wfile2

for i in `cut -f1 $wfile1`; do if [ $i -gt $size_plateau ]; then grep $i
$wfile1 >> $wfile2; fi; done
for i in `cut -f2 $wfile2`; do echo "Your Profile is getting too large.
You probably need to clean up your email or move some of your files in
your My Documents folder" | mail ${i##/*/} -s "You are close to reaching
your quota for file space on the server"; done

Of course things I think that could be better...

- I have two separate evaluation lines...

- I could move the 'body' of the email into a separate file

- I could tell them how much disk space is actually being used and how
much more that they have available.

Thankfully, their profiles and their home directories both have their
actual user names. When I get down to group storage quotas, I'm actually
really going to have to work things through.

Part of the learning experience is actually trying to work these things
through...I just wish it didn't take me most of the day to write this
simple script - I am very slow.

Craig

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss