@echo off :***************************************** : QTREE QUOTA SCRIPT : quota.bat : : Written by: Michael Grey : Toronto Transit Commission : : This script must be changed to work : with you Filer : : You must also obtain a few utilities : to use this script properly. They are: : blat.exe, cut.exe, egrep.exe, eval.exe, : grep.exe, rsh.exe, & tr.exe : : This code may not be the best way of : processing and formatting the information : but it works. : : This script sends warnings once a week and : re-sets the .WRN files : : : Date: January 15, 2002 :***************************************** :***************************************** : set environment variables :***************************************** set PurgeDay=Sun : the DIST_LIST variable is the e-mail address of the Filer Administrators : Separate entries with a "," set DIST_LIST=first.last@company.com,You@mail.com set working_path=\\filer\c$\etc\scripts set quotas_file=\\filer\c$\etc\scripts\temp\quotas_file.txt set quotas_temp_file1=\\filer\c$\etc\scripts\temp\quotas_temp_file1.txt set quotas_temp_file2=\\filer\c$\etc\scripts\temp\quotas_temp_file2.txt set summary_report=\\filer\c$\etc\scripts\summary_report.txt :***************************************** : Purge .WRN files on %PurgeDay% :***************************************** Date /T | findstr %PurgeDay% > NUL && (del /q %working_path%\temp\*.wrn) :***************************************** : Overwrite existing %quotas_file% and : create headers with data and time :***************************************** date /T > %quotas_file% time /T >> %quotas_file% :***************************************** : RSH to Filer to generate a Quota Report : Store the output in the quotas_file :***************************************** rsh Filer quota report >> %quotas_file% :***************************************** : put the %quotas_file% into a format that is usable :***************************************** : Strip the Quotas file and extract line that contain the word "tree" %working_path%\egrep "tree" %quotas_file% > %quotas_temp_file1% : Strip the Quotas file of all extra spaces %working_path%\tr -s ' ' < %quotas_temp_file1% > %quotas_temp_file2% : Replace the Spaces with Tabs %working_path%\tr " " "\t" < %quotas_temp_file2% > %quotas_temp_file1% : Only columns 4,5,6 contain data that we require, strip off the rest %working_path%\cut -f4-6 %quotas_temp_file1% > %quotas_temp_file2% : Replace the tabs with Commas %working_path%\tr "\t" "," < %quotas_temp_file2% > %quotas_temp_file1% :***************************************** : Overwrite existing Summary Report and setup current processing :***************************************** @echo Filer QTREE Quota Summary Report > %summary_report% @echo. >> %summary_report% date /T >> %summary_report% time /T >> %summary_report% @echo. >> %summary_report% :***************************************** : Process all the entries in the %quotas_temp_file1% : As part of the process it calls out to quota2.bat :***************************************** for /F "eol= tokens=1,2,3 delims=, " %%i in (%quotas_temp_file1%) do call quota2.bat %%i %%j %%k :***************************************** : Send Notification that the Script Completed :***************************************** : You must replace X.X.X.X with your mail servers IP Address. %working_path%\blat.exe %working_path%\blat.exe -to %DIST_LIST% -f Storage.Allocation@yourcompany.com -subject "Filer QTREE Quota Script Completed" -server X.X.X.X -body "For a summary of the processing results please view the following file: %summary_report% To Review all the Filer QTREE Summary Reports click on this link: \\Filer\c$\etc\scripts\Archived_Quota_Summary_Reports" -q :***************************************** : Place a copy of the Summary Report to Archives :***************************************** : Get the Date in a format that is valid to save a file as (MM.DD.YYYY) date /t | tr "/" "." > %working_path%\temp\date.txt for /F "eol= tokens=2 delims= " %%i in (%working_path%\temp\date.txt) do set Today_Date=%%i copy %working_path%\filer_summary_report.txt %working_path%\Archived_Quota_Summary_Reports\%today_Date%.txt :***************************************** : Exit Script :***************************************** : the_end