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

  1. #!/usr/local/bin/kermit +
  2. #
  3. # This is the DELIVER script from page 453 of "Using C-Kermit", 2nd Edition,
  4. # with a couple typos fixed.  C-Kermit 6.0 or K95 1.1.8 or later required,
  5. # and it also requires that the definition of the ACCESS macro (see text,
  6. # Chapter 19) from the standard C-Kermit initialization file be defined
  7. # already.  This script uses the ACCESS macro to make a connection to the
  8. # desired service and send it the desired file or files.  If the transfer
  9. # fails (e.g. because the connection is broken), a new connection is made
  10. # and the transfer is resumed from the point of failure.
  11. #
  12. # In UNIX, this can be used as a "kerbang" script, and invoked from the UNIX
  13. # prompt with the service name, filename, and optional reconnection limit as
  14. # arguments, e.g. "deliver headquarters budget.xls 500".  The Kerbang
  15. # features require C-Kermit 7.0.
  16. #
  17. # Authors: C. Gianone & F. da Cruz, Columbia University, 1997.
  18.  
  19. COMMENT - DELIVER macro
  20. ;  \%1 = service name
  21. ;  \%2 = filename (can be wild)
  22. ;  \%3 = Maximum tries allowed (default = 1000)
  23. ;
  24. define DELIVER {
  25.     local \%i \%p             ; Local variables
  26.     set input timeout proceed
  27.     if not def \%3 def \%3 1000
  28.     while not def \%p {
  29.         askq \%p { Password for \%1 }
  30.     }
  31.     set file type binary      ; Transfer mode must be binary
  32.     for \%i 1 \%3 1 {
  33.         if > \%i 1 {          ; If not the first try
  34.             hangup            ; hang up and print message
  35.             echo CONNECTION BROKEN.
  36.             Echo Reconnecting...
  37.         }
  38.         access \%1 \%p        ; Make the connection and log in
  39.         if fail continue      ; Keep trying
  40.         out kermit\13         ; Start Kermit on remote system
  41.         input 10 >            ; Wait for prompt
  42.         out receive\13        ; Tell it to RECEIVE
  43.         input 10 KERMIT READY ; Wait for READY message
  44.         pause 1               ; Plus a second for safety
  45.         resend \%2            ; RESEND the file(s)
  46.         if success break
  47.     }
  48.     if > \%i \%3 -
  49.       end 1 FAILED after \%3 tries.
  50.     output logout\13          ; Success, log out
  51.     pause 5                   ; Give it time...
  52.     hangup                    ; Hang up
  53.     end 0 \%2 delivered after \%i tries
  54. }
  55.  
  56. # This part requires C-Kermit 7.0...
  57.  
  58. if LLT \v(version) 60000 end 0
  59. define usage { exit 1 Usage: \fbasename(\v(cmdfil)) service file(s) }
  60.  
  61. if equal "\%0" "\v(cmdfil)" {
  62.     if < \v(argc) 3 usage
  63.     if not def access exit 1 Fatal - ACCESS macro is not defined.
  64.     deliver {\%1} {\%2} \%3
  65.     exit \v(status)
  66. }
  67.