[8122] in SIPB bug reports

home help back first fref pref prev next nref lref last post

Re: wrapper script for pine

daemon@ATHENA.MIT.EDU (Arun A Tharuvai)
Mon Jul 15 15:10:19 2002

To: peeto de la noche <gamache@ftso.org>
Cc: Greg Hudson <ghudson@mit.edu>, "bug-sipb@MIT.EDU" <bug-sipb@mit.edu>
From: Arun A Tharuvai <aatharuv@MIT.EDU>
Date: 15 Jul 2002 15:10:11 -0400
In-Reply-To: <Pine.NEB.4.44.0207151505350.16705-100000@north-vietnamese-army.ftso.org>

--=-=-=

Here's a fixed wrapper script that deals with from output.



--=-=-=
Content-Type: application/x-perl
Content-Disposition: attachment; filename=pine-wrapper.pl
Content-Description: wrapper script

#!/usr/athena/bin/perl

# wrapper script to make sure pine doesn't eat mail
# gamache  15 july 2002
#

use strict;

my @quota_out = split "\n", `quota -v`;
my $username = $ENV{USER};

my $safetycheck = 1000000 ; # A safety margin.
my @fromarray = split /\s/, `from -t`;
$fromarray[4] =~ s/\(//;


foreach my $line (@quota_out) {
      if ( $line=~/$username\s+([0-9]+)\s+([0-9]+)/ ) {
         my $used_kb = $1;
         my $quota_kb = $2;
	 my $totalspace = $used_kb + ( $fromarray[4] + $safetycheck) / 1000 ;
	 if ( $totalspace >= $quota_kb ) {
	     print "\nWARNING:\n";
	     print "You currently are using $used_kb kilobytes and have $fromarray[4]\nkilobytes of mail on the server.\n";
	     print "If you continue you will go over your quota of $quota_kb kilobytes and lose email.\n";
	     print "Aborting.\n\n";
	     exit 0;
	 }

		 
         if ( $used_kb/$quota_kb >= 0.9 ) {
            print <<EOT

WARNING:
You appear to be using 90% or more of your disk quota.  If you inc
mail with pine, there is a chance that messages will be lost if you
exceed your disk quota.  Proceed anyway? (yes/no)
EOT
;

            my $answer = <>;
            if (! ($answer=~/^yes\s*$/i || $answer=~/^y\s*$/i) ) {
                # anything other than 'y' or 'yes', case-insensitive
                print "Aborting.\n\n";
                exit 0;
            }
        }
     }
}

exec "athrun","sipb","pine.nonimap";

--=-=-=--

home help back first fref pref prev next nref lref last post