- 论坛徽章:
- 0
|
原帖由 redjade 于 2006-12-4 17:35 发表
我在本地windows机器上运行emacs, 现在可以用FTP登录到远程solaris机器, 进行远程文件编辑和保存.
可是我想知道,如何能登录到远程机器上,执行shell命令.
telnet, windows自带的telnet不行, 建议你装下cygwin
在.emacs下配置:
(setenv "PATH" (concat "C:/cygwin/bin;" (getenv "PATH")))
(setq exec-path (cons "C:/cygwin/bin/" exec-path))
(require 'cygwin-mount)
(cygwin-mount-activate)
(add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t)
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt nil t)
(setq explicit-shell-file-name "bash.exe")
;; For subprocesses invoked via the shell
;; (e.g., "shell -c command")
(setq shell-file-name explicit-shell-file-name)
(require 'telnet)
(defun telnet (host)
"Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer `*PROGRAM-HOST*'
where PROGRAM is the telnet program being used. This program
is controlled by the contents of the global variable
`telnet-host-properties', falling back on the value of the
global variable `telnet-program'. Normally input is edited
in Emacs and sent a line at a time."
(interactive "sOpen connection to host: ")
(let* ((comint-delimiter-argument-list '(?\ ?\t))
(properties (cdr (assoc host telnet-host-properties)))
(telnet-program (if properties (car properties) telnet-program))
(name (concat telnet-program "-" (comint-arguments host 0 nil) ))
(buffer (get-buffer (concat "*" name "*")))
(telnet-options (if (cdr properties)
(cons "-l" (cdr properties))))
process)
(if (and buffer (get-buffer-process buffer))
(pop-to-buffer (concat "*" name "*"))
(pop-to-buffer
(apply 'make-comint name telnet-program nil telnet-options))
(setq process (get-buffer-process (current-buffer)))
;;(set-process-filter process 'telnet-initial-filter)
;; Don't send the `open' cmd till telnet is ready for it.
;;(accept-process-output process)
(erase-buffer)
(send-string process (concat "open " host "\n"))
(telnet-mode)
(setq telnet-remote-echoes nil)
(setq telnet-new-line "\n") ;; needed for cygwin 1.3.11
(setq comint-input-sender 'telnet-simple-send)
(setq telnet-count telnet-initial-count)
(setq comint-process-echoes t)
)))
|
|