; IF setconsole("hide") ; ENDIF ; ; NT/95 diskuse + message - Kixtart 3.63, 4.00 ; ; (c) scripting@wanadoo.nl 2001 ; ; vs 1.04 - program ; ; 1.00 (20010525) original version ; 1.01 (20010620) - MBytes notation changed in KBytes ; - contents of "root" wasn't count. ; - cleanup $log_file ; 1.02 (20010701) - fix: no limit to length of variable names ; ($number_of_directories => $number_of_dirs) ; 1.03 (20010710) - standardization of $debug_file value ; 1.04 (20011115) - fix: possible root problem ; (input by Peter Pulfer) ; - suppress SetConsole("hide") ; $prgrm_version="1.04" ; $tmp_directory=ExpandEnvironmentVars("%tmp%") IF (substr($tmp_directory,len($tmp_directory),1) <> "\") $tmp_directory=$tmp_directory+"\" ENDIF ; -------------------------------------------------------------------------- ; - - ; -------------------------------------------------------------------------- ; 1. specifies directories to check ; 2. specifies or read max diskspace from specified $space_file ; --------------------------------------------------------------------------- ; user definable part ; --------------------------------------------------------------------------- $debug_mode="yes" ; - yes/no - no = no user output will be viewed $debug_file=$tmp_directory+"kix-info.log" $log_file="c:\diskuse.log" ; <+++++ $number_of_dirs=1 DIM $dirs[$number_of_dirs+1] IF (len(@homedrive) <> 0) $dirs[1]=@homedrive ; <- by a fixed drive you may also use f.e. "s:" ELSE $dirs[1]="c:\work" ENDIF $space_file="x:\server\space_definitions.txt" ; <+++++ $max_space=ReadProfileString($space_file,"diskspace",@userid) IF (@error <> 0) AND ($max_space <= 24) ; <- change "24" to default value - 1 $max_space=25 ; " MBytes" ; <- change to default value ENDIF $max_space=1024*$max_space ; "MBytes -> KBytes" ; --------------------------------------------------------------------------- ; ; --------------------------------------------------------------------------- $number_of_files=1 ; <- increase value by new files to check for DIM $files[$number_of_files+1] $files[1]="*.*" $tmp_file=$tmp_directory+"kixtart.tmp" ; IF (Exist($debug_file) = 1) del $debug_file ENDIF IF ($debug_mode = "yes") IF (RedirectOutput($debug_file) <> 0) ENDIF ENDIF ? "KIX-DU "+@kix+" (vs "+$prgrm_version+")"+" "+@date+" "+@time ? IF (Exist($tmp_file) = 1) del $tmp_file ENDIF $eof="~~~ The command completed succesfully ~~~" ; $i=1 WHILE ($i <= $number_of_dirs) $k=1 IF (substr($dirs[$i],len($dirs[$i]),1) <> "\") $dirs[$i]=$dirs[$i]+"\" ENDIF IF ($debug_mode = "yes") ? "check directory: "+$dirs[$i] ENDIF WHILE ($k <= $number_of_files) $entry=$dirs[$i]+$files[$k] IF (exist($dirs[$i]) = 1) SHELL "%comspec% /c echo "+substr($dirs[$i],1,len($dirs[$i])-1)+" >>"+$tmp_file SHELL "%comspec% /c dir "+CHR(34)+$entry+CHR(34)+" /a:d /b /o:n /s >>"+$tmp_file ENDIF $k=$k+1 LOOP $i=$i+1 LOOP SHELL "%comspec% /c echo "+$eof+">>"+$tmp_file ? "check files: "+$files[1] $i=2 WHILE ($i <= $number_of_files) ? " "+$files[$i] $i=$i+1 LOOP ? $total_size=0 $total_dirs=0 $total_files=0 IF (Exist($tmp_file) = 1) IF (Open(1,$tmp_file,2) = 0) $completed="no" WHILE ($completed <> "yes") $result=LTRIM(RTRIM(Readline(1))) IF (@error <> 0) or (instr($result,$eof) <> 0) $completed="yes" ELSE IF (exist($result) = 1) $total_dirs=$total_dirs+1 GOSUB show_file_info ENDIF ENDIF LOOP IF Close(1) ENDIF ENDIF ENDIF $total_size=$total_size/1024 IF (Exist($tmp_file) = 1) del $tmp_file ENDIF ? IF ($total_dirs+$total_files = 0) ? "completed. found no entries." ELSE ? "completed. found " $total_dirs+$total_files " entries with total size of "+$total_size+" KBytes." ENDIF ? IF (RedirectOutput("") <> 0) ENDIF IF ($debug_mode = "yes") ? "Informative DU: output written to file '"+$debug_file+"'." ? ? " # dirs "+$total_dirs ? " # files "+$total_files ? " # size "+$total_size+" Kbytes" ? ENDIF IF (@inwin = 1) $user=@userid+substr(" ",1,25-len(@userid))+"NT" ELSE $user=@userid+substr(" ",1,25-len(@userid))+"95" ENDIF IF ($total_size > $max_space) IF WriteProfileString($log_file,"diskuse",$user,"") ENDIF IF WriteProfileString($log_file,"diskuse-max",$user,@date+" "+@time+" "+substr(" ",1,15-len("$total_size"))+$total_size+" "+$max_space) ENDIF ELSE IF WriteProfileString($log_file,"diskuse-max",$user,"") ENDIF IF WriteProfileString($log_file,"diskuse",$user,@date+" "+@time+" "+substr(" ",1,15-len("$total_size"))+$total_size+" "+$max_space) ENDIF ENDIF IF ($total_size > $max_space) ? "Warning DU: you are using to must diskspace." ? " Actual value "+$total_size+" KBytes. Legal value "+$max_space+" KBytes." ENDIF EXIT :show_file_info $count=0 $size=0 IF (substr($result,len($result),1) = "\") $result=substr($result,1,len($result)-1) ENDIF $filename=Dir($result+"\*.*") WHILE ($filename <> "") AND (@error = 0) IF GetFileAttr($result+"\"+$filename) & 16 ; - directory - ELSE IF ($filename <> ".") AND ($filename <> "..") $count=$count+1 ENDIF $size=$size+GetFileSize($result+"\"+$filename) ENDIF $filename=Dir() LOOP ; $total_files=$total_files+$count $total_size=$total_size+$size IF ($debug_mode = "yes") ? substr(" ",1,7-len("$count")) $count " " substr(" ",1,9-len("$size")) $size " ==> "+$result ENDIF RETURN