Skip to content

Instantly share code, notes, and snippets.

@takeshy
Created March 31, 2011 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeshy/895709 to your computer and use it in GitHub Desktop.
Save takeshy/895709 to your computer and use it in GitHub Desktop.
emacs scp
(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