Newsgroups: vmsnet.networks.desktop.pathworks
Subject: Procedure to check folderdepth
From: hellings@amc.uva.nl
Date: Mon, 14 Sep 1992 16:13:39 GMT
Organization: Central computer department

Dear Newsreader,
A while ago I updated my Appleshare fileserver on our VMS-VAX. One of the
problems was that some users had used a folderdepth of more than 7. The
fileserver update wasn't correctly done for those folders.
With the new Pathworks for Macintosh(1.1) the maximum folderdepth can easily
be exceeded by moving folders into folders. So we wrote a little program to 
warn uses about their execeeding of the maximun folder depth.
Installing the procedure:
1) define batch_oper
2) assign system$util
3) put the program into system$util

+++++++++++++++++++++++++++++++++the procedure+++++++++++++++++++++++++++++++
$!=============================================================================
$! Name:
$! Location:
$! Function:procedure file to warn fileserver manager if the folder-depht
$! is greater than 7. The mail send to him will tell him that folder's
$! deeper than 7 can't be backed up. The mail contents also which
$! folder gives the problem
$! History:
$! date		Modification				By
$! 9/9/1992	Created					HS
$!
$!=============================================================================
$ ! standard com file cca op1 is the name of the procedure
$!1_initialisation
$!
$! 1. stop external definitions
$	copy := "copy"
$	delete := "delete"
$	rename := "rename"
$!
$!
$! 2. save environment
$	op1_old_verify	= f$verify()
$	op1_old_privs	= F$getjpi("","curpriv")
$	op1_old_default	= F$environment("default")
$! 3. interruptr and error handlers,default is succes
$	on control_y	then goto 91_control_y
$	on warning	then goto 92_error
$!
$! 5. own definitions
$	ask	:= "read sys$command/prompt="
$	ws	:= "write sys$output"
$	batch_oper := "your queue"
$!
$! 6. the command procedure
$!                    
$!
$! 1. Define Array of Sever's and Managers
$!
$ server_amount = 4
$! fileserver1 = "DISK$USER3:[SCHAAP]"
$!       user1 = "SCHAAP"
$ fileserver1 = "DISK$USER2:[CCA]"
$       user1 = "HELLINGS"
$ fileserver2 = "DISK$USER2:[MSAF$GUEST]"
$       user2 = "HELLINGS"
$ fileserver1 = "DISK$USER2:[CARDIO_FILESERVER]"
$       user1 = "ZOCCA"
$ fileserver4 = "DISK$USER2:[MEDFYS]"
$       user4 = "LOUTER"
$ !
$ ! 
$ ! 2. Define Global Variables and own definitions
$ !
$ level == 1     
$ high_level == 1
$ mail_head == 0
$ ws = "write sys$output"
$ wm = "write mail"
$ !
$ !
$ ! 3. Make batch job restartable                 
$ !                                               
$ if $restart                                     
$ then                                            
$   if F$type(batch$restart) .nes. "" then-       
$     if batch$restart .eqs. "RESUB" then goto 99_exit
$   goto do_submit                                
$ endif                                           
$ !                                               
$ !
$ ! 4. Call procedure for all fileserver's
$ !
$ index = 1
$ main_loop:
$   fileserver = fileserver'index
$   user = user'index
$ if f$search("''fileserver'*.*") .nes. "" 
$ then
$ 	ws " fileserver is ''fileserver' and user is ''user'"
$   	call determine_depht "''fileserver'" "''user'" 
$  	index = index + 1
$ else
$ 	ws " fileserver ''fileserver' doesn't exist"
$ endif
$!
$ if index .le. server_amount
$ then
$   if mail_head
$   then
$     type system$util:mail.tmp
$     ! mail/subject="Warning message form System" system$util:mail.tmp 'user'
$   endif
$   mail_head == 0
$   goto main_loop
$ else
$   goto do_submit
$ endif
$ !
$ !
$ ! 5. determine depht and send mail if needed
$ !
$ determine_depht:
$ subroutine
$ !
$ set default 'p1'
$ !
$ loop:
$   level == 1
$   root_dir = f$search("*.dir;*")
$   if root_dir .nes. ""
$   then
$     call sub_dir "''root_dir'"
$   else
$     exit                         ! Return to main_loop
$   endif
$ goto loop
$ endsubroutine
$ !
$ sub_dir:
$ subroutine
$   level == level + 1
$   pos = f$locate("]",p1)                           
$   s_dir = f$extract(pos+1,f$length(p1),p1)
$   s_dir = s_dir - ".DIR;1"                         
$   set default [.'s_dir']
$ doit_again:
$   n_dir = f$search("*.dir;*")
$   if n_dir .nes. "" .and. level .le. 7
$   then
$     call sub_dir "''n_dir'"
$     goto doit_again
$   else ! on level 8 no more subdir's
$     if level .gt. 7 then call send_mail
$     if level .gt. high_level then high_level == level
$     level == level - 1
$     set default [-]
$     return                ! Return to doit_again or loop
$   endif
$ endsubroutine
$ !
$ !
$send_mail:
$ subroutine
$   !
$   ! Create temporarily file for mail message
$   !
$   mail_head == 1
$   def_dir = f$directory()
$   if mail_head .eq. 0
$   then
$     open/write/error=file_error mail system$util:mail.tmp
$     wm ""
$     wm "The folder-depht on fileserver ''fileserver' exceeded 7 levels."
$     wm "Folders deeper then 7 levels won't be backed up."
$     wm "Please, fix the problem by moving some subdirectory's"
$     wm "to higher levels."
$     wm ""
$     wm "You need to move the directory's below :"
$     wm ""
$     wm "''def_dir'"
$     close mail
$   else
$     open/append/error=file_error mail system$util:mail.tmp
$     wm "''def_dir'"
$     close mail
$   endif
$   exit
$ endsubroutine
$ !
$ !
$ ! submit batch job every 24 hours at 1:00
$ !
$ do_submit:
$  submit/noprint/log=system$util:folder.log/name=folder_depth/-
queue=batch_oper/after="tomorrow"/restart system$util:folder.com
$   set restart_value = resub
$ !
$ !
$ ! Terminate the command procedure
$ !
$19_end:
$! etc.

$	goto 98_clean_up
$!
$! 6.finishing
$!
$91_control_y:
$ ws "%FOLDER-I-CTLYEX, you used control_y. The procedure will be stopped"
$ goto 98_clean_up
$!
$92_error:
$ ws "%FOLDER-E-ERROREX,  An error has occurred. The procedure will be stopped"
$ goto 98_clean_up
$!
$98_clean_up:
$! finishing commands, like closing file and restorering environment
$ 	op1_dummy = f$verify(op1_old_verify)
$	set process/privileges=(noall,'op1_old_privs')
$	set default 'op1_old_default'
$   	if f$search("system$util:mail.tmp;*") .nes. "" then -
 delete system$util:mail.tmp;*
$	delete/symbol/global level
$	delete/symbol/global high_level
$   	set restart_value = exit
$99_exit:
$ exit
==============================end of com procedure===========================
Thanks to Harry Schaap who wrote the program.
I'll hope it works!
***************************Jan Hellings*********************************
* University of Amsterdam	  Phone: (+31) 20 5662055	       *
* Faculty of medicine/AMC/D01-412 bitnet: hellings@hasamc51            *
* Meibergdreef 9			                               *
* 1105 AZ Amsterdam/Holland	  domain  : hellings@amc.uva.nl        *
************************************************************************

Newsgroups: vmsnet.networks.desktop.pathworks