$!-------------------------------------------------------------------------o $! ! $! C R U S H M A I L ! $! ! $! Author: franco.brunetta@libero.it Version 1.0-01 ! $! Created: 28-AUG-2001 ! $! Last revision: 29-AUG-2001 ! $! ! $!-------------------------------------------------------------------------o $! >>>DOCUMENTATION AT THE END OF THE PROCEDURE<<< ! $!-------------------------------------------------------------------------- $! Standard set-up $!-------------------------------------------------------------------------- $ ON ERROR THEN GOTO The_end $ ON CONTROL_Y THEN GOTO The_end !*CAUTION* using ^Y: may interrupt $! ! MAIL.MAI compression $ WW := Write Sys$Output $ This_dir = F$ENVIRONMENT("DEFAULT") $!--------------------------- $! What day is today? $!--------------------------- $ Tempo=F$TIME() $ Year=F$CVTIME(Tempo,,"YEAR") $ Month=F$CVTIME(Tempo,,"MONTH") $ Day=F$CVTIME(Tempo,,"DAY") $ Today = f$integer("''year'''month'''day'") $!---------------------------- $! Default parameters $!---------------------------- $ IF P1 .EQS. "" THEN P1 = "DISK$1:[000000...]MAIL.MAI;" $ IF P2 .EQS. "" THEN P2 = 1000 $ if f$locate("*",p1) .lt. f$length(p1) - !##1.0-1 .or. f$locate("%",p1) .lt. f$length(p1) - .or. f$locate("...",p1) .lt. f$length(p1) $ then single_file = "FALSE" $ else single_file = "TRUE" $ endif $!---------------------------- $ Loop: $ The_file = F$SEARCH(P1) $ IF The_file .EQS. "" THEN GOTO The_end $! $! the directory mail.mai lives in $! $ The_dir = F$ELEMENT(0,"]",The_file) + "]" $! $! MAIL.MAI file allocated blocks; will skip if size is too low $! $ Allo = F$FILE_ATTRIBUTE(The_file,"ALQ") $ Allo_skip = "" $ IF Allo .LT. P2 THEN Allo_skip=", low size" $! $! MAIL.MAI creation date; will skip if already compressed today $! $ CDT = F$EDIT(F$FILE_ATTRIBUTE(The_file,"CDT"),"TRIM") $ C_Year=F$CVTIME(CDT,,"YEAR") $ C_Month=F$CVTIME(CDT,,"MONTH") $ C_Day=F$CVTIME(CDT,,"DAY") $ C_today = f$integer("''c_year'''c_month'''c_day'") $ CDT_skip = "" $ IF C_today .EQ. Today THEN CDT_skip=", already modified today" $! $! OK, some information about this file $! $ WW "------------------------------------------" $ WW "FILE: ",the_file $ WW "Blocks: ",allo $ WW "CDT: ",cdt $! $! Must we skip it or not? $! $ IF Allo_skip .EQS. "" .AND. Cdt_skip .EQS. "" THEN GOTO Now_Compress $ ww "%CRUSHMAIL-W-SKIPPING''allo_skip'''cdt_skip'" $ IF Single_file then GOTO The_End $ GOTO Loop $!-------------------------------------------------------------------------- $! Now, compress; CAUTION ^Y or error should not occur here... $!-------------------------------------------------------------------------- $Now_Compress: $ SET DEFAULT 'the_dir' $ MAIL SET FILE sys$disk:[] COMPRESS EXIT $ directory/size=all/date=crea mail.* $ IF P3 .NES. "NODELETE" $ THEN IF P3 .NES. "NOCONFIRM" $ THEN DELETE/LOG/CONF MAIL.OLD; $ ELSE DELETE/LOG MAIL.OLD; $ ENDIF $ ENDIF $ IF .NOT. Single_file then GOTO Loop $!-------------------------------------------------------------------------- $! CLosing operations $!-------------------------------------------------------------------------- $the_end: $ SET DEFAULT 'This_dir' $ EXIT $!-------------------------------------------------------------------------! $!------------------------D O C U M E N T A T I O N -----------------------! $!-------------------------------------------------------------------------! $! C R U S H M A I L ! $! ! $! Time ago, when most of people used VMS with interactive ! $! sessions, they knew something about managing their home ! $! directory, as well as compressing, sometime, MAIL.MAI file. ! $! ! $! Now that people use very often VMS systems with ! $! POP/SMTP/IMAP connections, usually they never make ! $! telnet/interactive connections to the system; they don't ! $! know anything about managing home directory; they never ! $! compress their MAIL.MAI file. ! $! ! $! If you have a lot of users, receving a lot of messages ! $! everyday, their mail.mai file could grow greatly, and waste ! $! [a lot of} space on your disks. ! $! ! $! Since you cannot force your users to use telnet/interactive ! $! connections, using MAIL utility, compressing, deleting the ! $! mail.old file, and doing it often...well, here's a little ! $! utility that can help you doing it automagically. ! $! ! $! CRUSHMAIL scans a given file specification (for example, a ! $! single file spec. like MYDISK:[MYDIR.MYMAIL]MAIL.MAI, or a ! $! more complex one like DISK$1:[000000...]MAIL.MAI) and ! $! compress every MAIL.MAI file it finds. ! $! ! $! CRUSHMAIL doesn't compress a MAIL.MAI file if its size is ! $! not high enough (as given in P2 parameter); and doesn't ! $! compress a MAIL.MAI file if its creation date is 'today' (so ! $! you can use it often everyday, but compression will occur ! $! only once a day). ! $! ! $! You can optionally decide to avoid deletion of MAIL.OLD; or ! $! to delete it requesting a confirmation (for interactive use) ! $! or automatically (for non interactive use). ! $! ! $! ! $! Parameters used: ! $! ! $! P1 input file specification; ! $! default: DISK$1:[000000...]MAIL.MAI ! $! P2 minimum mail.mai's size; compression will not occur if ! $! size is below this limit. ! $! default: 1000 blocks ! $! P3 deletion control: ! $! NODELETE -> mail.old file will be saved (no ! $! deletion will occur) ! $! NOCONFIRM -> mail.old file will be deleted; no ! $! confirmation will be requested ! $! default: mail.old files will be deleted, requesting ! $! interactive confirmation ! $! ! $! Examples: ! $! ! $! @CRUSHMAIL DISK$1:[000000...]MAIL.MAI 1000 ! $! will compress all mail.mai file in the ! $! whole DISK$1; requires privileges. ! $! mail.old will be deleted, requesting ! $! interactive confirmation. If mail.mai's ! $! size will be lower of 1000 blocks, ! $! compression will not occur. What about ! $! using this command, e.g., once a month ! $! for every disk? ! $! ! $! @CRUSHMAIL DISK$2:[FRANCO.MYMAIL]MAIL.MAI 2000 NODELETE ! $! will compress only one user's mail.mai ! $! file; mail.old file will NOT be deleted ! $! (user must do it with interactive ! $! session). If mail.mai's size will be ! $! lower of 2000 blocks, compression will ! $! not occur. ! $! ! $! @CRUSHMAIL DISK$2:[FRANCO.MYMAIL]MAIL.MAI 2000 NOCONFIRM ! $! the same, but mail.old deletion will ! $! occur withoutconfirmation. What about ! $! putting this command in login.com? (but ! $! caution: will slow login; will display ! $! additional information) ! $! ! $! ! $! Tested with OpenVMS AXP 7.2. ! $! ! $! Comments and...donations to: franco.brunetta@libero.it ! $! ! $!-------------------------------------------------------------------------! $! History: ! $!-------------------------------------------------------------------------! $! ! $! V1.0 starting version. ! $! V1.0-01 double correction: documentation; input file scan ! $! error. ! $! ! $!-------------------------------------------------------------------------o