home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / ftpsyncup < prev    next >
Text File  |  2020-01-01  |  3KB  |  63 lines

  1. #!/usr/local/bin/kermit
  2. ;
  3. ; f t p s y n c u p
  4. ;
  5. ; Synchronizes a server directory tree from a local one.
  6. ;  . Local files that don't exist on the server are uploaded.
  7. ;  . Local files that exist on the server are uploaded only if newer.
  8. ;  . Local file timestamps are not preserved (FTP doesn't allow that).
  9. ;  . Server file permissions are not preserved 
  10. ;  . Ditto for file owner, group, ACLs, etc.
  11. ;  . Works across platforms via automatic text/binary mode switching.
  12. ;  . Works quietly but keeps a log of what it did.
  13. ;
  14. ; Directories are created on the server automatically as we descend through
  15. ; the local tree.
  16. ;
  17. ; Local file permissions are preserved on the server if the server and
  18. ; client are both Unix-based and the server permits SITE CHMOD.
  19. ;
  20. ; Server files that don't exist on the client are NOT deleted.
  21. ; It would be possible to script this, but ugly.  If this script was to
  22. ; handle only a single flat directory and not a directory tree, then it
  23. ; would be easy to delete extraneous files from the server (get file list
  24. ; with "mget /namelist:xxx *" then read filenames from xxx, "if exist"
  25. ; each one, ldelete it).
  26. ; Requires: C-Kermit 80 or later or K95 2.0 or later
  27. ;
  28. ; F. da Cruz, Columbia University, 24 Feb 2003
  29.  
  30. ; Parameters - Change as needed (or turn them into arguments)
  31.  
  32. .host = kermit.columbia.edu         ; Change to desired host
  33. .rdirectory = kermit/g              ; Change to desired host directory
  34. .ldirectory = ~/g                   ; Change to desired local directory
  35. .logfile := \v(home)ftpsync.log     ; Change to desired logfile name
  36.  
  37. ; End of parameter defintions.
  38.  
  39. set transaction-log brief           ; Choose brief transaction-log format
  40. set exit warning off                ; No "OK to exit?" prompts
  41. set quiet on                        ; Suppress progress messages
  42.  
  43. lcd \m(ldirectory)                  ; CD to desired local directory
  44. if fail exit 1 "LCD failed - \m(ldirectory)" ; Make sure we did
  45.  
  46. ftp open \m(host) /anonymous        ; Open and check anonymous FTP connection
  47. if fail exit 1 Login failed
  48. if not \v(ftp_loggedin) exit 1 "Anonymous Login failed"
  49.  
  50. log transactions \m(logfile)        ; Start log
  51.  
  52. ftp cd \m(rdirectory)               ; CD to desired server directory
  53. if fail exit 1 "FTP CD failed - \m(rdirectory)"
  54.  
  55. ftp mput /recursive /update *       ; Put all local files in update mode
  56. if fail exit 1 "Mput failed"        ; Check for errors
  57.  
  58. bye                                 ; Disconnect from server
  59. close transaction-log               ; Close log
  60. cat \m(logfile)                     ; Display log
  61. exit 0
  62.