home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / vms / 20830 < prev    next >
Encoding:
Text File  |  1993-01-12  |  4.8 KB  |  141 lines

  1. Newsgroups: comp.os.vms
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!slacvx.slac.stanford.edu!fairfield
  3. From: fairfield@slacvx.slac.stanford.edu
  4. Subject: COPYTREE.COM (Was: Need: Multi dir copy between nodes.)
  5. Message-ID: <1993Jan12.171854.1@slacvx.slac.stanford.edu>
  6. Lines: 129
  7. Sender: news@unixhub.SLAC.Stanford.EDU
  8. Organization: Stanford Linear Accelerator Center
  9. References: <01GTFHS4SK4Y95OOX3@wl.aecl.ca>
  10. Date: Wed, 13 Jan 1993 01:18:54 GMT
  11.  
  12. In article <01GTFHS4SK4Y95OOX3@wl.aecl.ca>, LITWINK@WL.AECL.CA (Keith Litwin) writes:
  13. > Does anyone know of a utility to copy entire directory trees and contents
  14. > between nodes without using a saveset?
  15.  
  16.     Yes :-)   I cooked this up a couple years ago when I had to move 
  17. a set of users from one cluster to another at our site.  Backup wasn't
  18. an option for most (I would've had to do it for them).
  19.  
  20.     I've included COPYTREE.COM below by sig.  It works locally, but was
  21. designed to work between nodes using DECnet syntax.  I made sure my users
  22. had proxy access to the remote node (the "source" node in our case) so that
  23. passwords weren't slung about freely over the network, but it will work fine
  24. with the usual NODE"username password":: specification.
  25.  
  26.     Two key features to this command file: (1) the "source" and "destination"
  27. directories may be subdirectories themselves, and (2) I've tried to 
  28. reestablish the VMS default protection on .MAI files and MAIL.DIR (if
  29. you have one) and its subdirectories.
  30.  
  31.     I think the comments in the header describe things well enough, but
  32. if need be, drop me a note and I'll try to answer questions.
  33.  
  34.     Use and enjoy!  Ken
  35. -- 
  36.  Dr. Kenneth H. Fairfield    |  Internet: Fairfield@Slac.Stanford.Edu
  37.  SLAC, P.O.Box 4349, MS 98   |  DECnet:   45537::FAIRFIELD (45537=SLACVX)
  38.  Stanford, CA   94309        |  BITNET    Fairfield@Slacvx
  39.  ----------------------------------------------------------------------------
  40.  These opinions are mine, not SLAC's, Stanford's, nor the DOE's...
  41.  
  42. ---------------cut/here---------COPYTREE.COM-----------cut/here--------------
  43. $!
  44. $!        C O P Y T R E E . C O M
  45. $!        =======================
  46. $!
  47. $!    Command procedure copies a complete directory tree from one "root"
  48. $!    to another, including between VAXes.
  49. $!
  50. $!    File and directory protection masks are taken from the source
  51. $!    directory and its subdirectories.  The destination root directory
  52. $!    protection mask (only) made be specified on the command line if
  53. $!    it is to be different than the source directory root.
  54. $!
  55. $! Input Parameters:
  56. $!
  57. $!    p1 - Source root directory.  This should include the full
  58. $!         directory specification, e.g. NODE::DEV:[DIRECTORY],
  59. $!         where NODE:: is optional.  The source root may include
  60. $!         one or more subdirectories.
  61. $!
  62. $!    p2 - Destination root directory.  Specify in the same way as p1.
  63. $!
  64. $!    p3 - File protection string for creating p2 (optional)
  65. $!
  66. $    If p1 .Eqs. "" Then Inquire p1 "Input root"
  67. $    If p2 .Eqs. "" Then Inquire p2 "Output root"
  68. $    If p3 .Nes. ""
  69. $    Then
  70. $       dirprot = "/Prot=(" + p3 + ")"
  71. $       fprot   = "/Prot=(" + F$Element(0, ",", p3) + "D," -
  72.                    + F$Element(1, ",", p3) + "D," -
  73.                    + F$Element(2, ",", p3) + ","  -
  74.                    + F$Element(3, ",", p3) + ")"
  75. $    Else
  76. $       lastdir = ""
  77. $       n=0
  78. $ DIRLOOP:
  79. $       thisdir = F$Element (n, ".", p1)
  80. $       If (thisdir .Nes. ".")
  81. $       Then
  82. $          lastdir = "." + thisdir
  83. $          n=n+1
  84. $          Goto DIRLOOP
  85. $       Else
  86. $          If (lastdir .Nes. "")
  87. $          Then
  88. $         bclose = F$Extract (F$Length(p1)-1, 1, p1)
  89. $         thisdir = lastdir - "." - bclose
  90. $         parent  = p1 - lastdir + bclose + thisdir + ".DIR;1"
  91. $         dirprot = "/Prot=(" + -
  92.             F$Edit (F$File_Attributes (parent, "PRO"), "COLLAPSE") -
  93.                 + ")"
  94. $          Else
  95. $         dirprot = " "
  96. $          Endif
  97. $       Endif
  98. $       fprot   = " "
  99. $    Endif
  100. $
  101. $!
  102. $    Set Noon
  103. $    Create/Dire/Log'dirprot' 'p2'
  104. $    crestat = $Status
  105. $    If .Not.crestat
  106. $    Then
  107. $    Else
  108. $       If crestat .Eq. %X10911293
  109. $       Then
  110. $          Inquire yn "Do you wish to continue? (y/n)"
  111. $          If yn Then Goto OK
  112. $       Else
  113. $          Goto OK
  114. $       Endif
  115. $    Endif
  116. $    Exit 'crestat'
  117. $!
  118. $ OK:
  119. $    Write Sys$output " Copying " + p1 + "*.*;*  -->  " + p2 + "*.*;*"
  120. $    Copy 'p1'*.*;*/Exclude=(*.DIR;1,NETSERVER.LOG;*) 'p2'*.*;*'fprot'
  121. $    Set On
  122. $!
  123. $!  Re-establish correct (VMS default) protections on MAIL files.
  124. $!
  125. $    If F$Search("''p2'*.mai;*") .Nes. "" Then -
  126.         Set Prot=(SYSTEM:RW, OWNER:RW, GROUP, WORLD) 'p2'*.MAI;*
  127. $!
  128. $ LOOP: next = F$Search(p1+"*.DIR;1")
  129. $    If next .Eqs. "" Then Exit 1
  130. $!
  131. $!!!    Set Message/Nofacil/Noiden/Notext/Nosev
  132. $!!!    newprot = ""
  133. $    newprot = F$Edit (F$File_Attrbutes (next, "PRO"), "COLLAPSE")
  134. $!!!    Set Message/Facil/Iden/Text/Sev
  135. $!
  136. $    next = F$Parse(next,,,"NAME")
  137. $    input_dir  = p1 - "]" + "." + next + "]"
  138. $    output_dir = p2 - "]" + "." + next + "]"
  139. $    @'F$Environment("PROCEDURE") 'input_dir' 'output_dir' 'newprot'
  140. $    Goto LOOP
  141.