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

  1. ; n e t e d i t
  2. ;  
  3. ; Edit a remote file on the local computer.  Automatically downloads the file,
  4. ; loads into your preferred editor, and uploads the edited result.  Use SET
  5. ; EDITOR to configure your preferred editor, SHOW EDITOR to show it.
  6. ;
  7. ; Use NETEDIT when already logged into another computer with Kermit.  TAKE
  8. ; this file to define the NETEDIT macro (or add the NETEDIT definition to your
  9. ; Kermit customization file), and then type "netedit filename" at the local
  10. ; Kermit prompt whenever you want to edit a remote file.
  11. ;
  12. ; Requires C-Kermit 7.0 or Kermit 95 1.1.19 or later.
  13. ;
  14. ; F. da Cruz, Columbia University, May 2000.
  15. ;
  16. def NETEDIT {
  17.     local current status
  18.     if not \v(local) end 1 No connection ; Works only in local mode
  19.     while not defined \%1 {              ; Prompt for filename if not given.
  20.         ask \%1 { Filename? }
  21.     }
  22.     asg current \v(directory)            ; Save current directory
  23.     if def \v(download) cd \v(download)  ; CD to download directory
  24.     set transfer display brief           ; No flourishes
  25.     lineout kermit -x                    ; Start Kermit server on remote
  26.     get /text \%1                        ; Get the file text mode
  27.     if fail end 1 Download failed        ; Make sure it worked
  28.     edit \%1                             ; Edit the file
  29.     if fail end 1 Edit failed            ; Make sure it worked
  30.     if not exist \%1 {
  31.         end 1 File "\%1" missing after edit - Did you change its name?
  32.     }
  33.     send /text \%1                       ; Send the edited file back
  34.     asg status \v(status)                ; Remember SEND return code
  35.     finish                               ; Shut down the remote Kermit server
  36.     if = \v(status) 0 {                  ; If OK delete the file
  37.         echo UPLOAD OK.
  38.         delete \%1                       
  39.         if success echo Local copy deleted.
  40.     } else {
  41.         echo UPLOAD FAILED.
  42.         echo Edited file retained: \fpathname(\%1)        
  43.     }
  44.     cd \m(current)                       ; Return to previous directory
  45.     end \m(status)             ; Done
  46. }
  47.