Created
March 31, 2011 02:21
-
-
Save takeshy/895709 to your computer and use it in GitHub Desktop.
emacs scp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun post-ftp() | |
"Post current file to Server." | |
(interactive ) | |
(setq nowfile (buffer-file-name)) | |
(setq before_buffer (buffer-name)) | |
(setq dir_pos (string-match "/[^/]*$" nowfile)) | |
(setq dir_name (substring nowfile 0 dir_pos)) | |
(setq remote_dir_name (substring nowfile (length "c:/") dir_pos)) | |
(setq file_name (substring nowfile (+ 1 dir_pos) (length nowfile))) | |
(find-file "c:\\tmp\\scpcmd.txt") | |
(erase-buffer) | |
(insert "option batch on\n") | |
(insert "open USER_NAME@SERVER_ADDRESS\n") | |
(insert (concat "cd " remote_dir_name "\n")) | |
(insert (concat "lcd " dir_name "\n")) | |
(insert (concat "rm " file_name "\n")) | |
(insert (concat "put " file_name "\n")) | |
(insert "exit\n") | |
(save-buffer) | |
(kill-buffer (buffer-name)) | |
(call-process "C:\\Windows\\System32\\cmd.exe" nil nil nil "/c" "C:\\Program Files (x86)\\WinSCP\\winscp.exe" "/console" "/script=c:\\tmp\\scpcmd.txt") | |
(switch-to-buffer before_buffer) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment