<List folk: this is the impromptu skeleton of the NT FAQ item I intend
to write. If you see anything wrong, or believe something's missing,
or have better wording, please lemme know.>             

Rodney Sparapani <[EMAIL PROTECTED]> Wed, 07 Mar 2001 15:58:39 -0600
> What did you have to do to get Tramp working on emacs for Windows?
> I've been trying all day and I must be missing something. emacs 20.7
> with Windows 2000 and Cygwin 1.1.8

I didn't use Cygwin :-) Seriously--Cygwin is probably the better way
to go, but I've had problems in the past setting it up. You might
wanna try a non-Cygwin setup first. Or you might wanna ignore this,
and find someone who's up on Cygwin. FWIW, I have tramp.el,v 2.0.2.1
working on GNU Emacs 20.7.1 (i386-*-nt5.0.2195) on w2k sp1.

I'm planning to do a HOWTO for this, but briefly (i.e. very sketchily,
ask if you have questions): a six-step plan.

0 Install 'putty' and 'plink' from the PuTTY package

  http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

  I'd recommend installing all the PuTTY stuff, but YMMV.

1 Run 'putty' to your target host, as a milestone. (I.e. if you can't
  get that working, there's a problem that you need to fix before
  proceeding.)

2 Eval for testing, or install in .emacs, the following elisp:

(setq remote-shell-program "plink") ; is "rsh" by default (paths.el)

;;; M-x plink-ssh makes an SSH connection in a *shell*-type buffer.
;;; (M-x plink does not).

; Bill Pringlemeir <[EMAIL PROTECTED]> 02 Mar 2001 10:59:40
; attempt by me to use ssh-1.7, per Hershberger
; I use shell-mode: it has more functionality

(setq plink-program "plink")
; (require 'telnet)
(defun plink-ssh (host)
  "Open a network login connection. See plink."
  (interactive "sOpen ssh connection to host: ")
  (plink host "-ssh"))

;; Telnet to host.
(defun plink (host &optional ssh-string)
  "Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer `*plink-HOST*'.
Normally input is edited in Emacs and sent a line at a time."
  (interactive "sOpen ssh connection to host: ")
  (require 'shell)
  (let ((name (concat "plink-" host))
        (password (comint-read-noecho "password: " t)))
    (pop-to-buffer 
      (make-comint name plink-program nil ssh-string host 
         "-pw" password))
; causes echoing of the Password: prompt in minibuffer? maybe
; but also prevents echoing of ^M ?
;    (set-process-filter (get-process name) 'telnet-initial-filter)
;    (telnet-mode)
    (shell-mode)
    (accept-process-output  (get-buffer-process (current-buffer)))
; Causes echoing of the Password: prompt in minibuffer? no
; Nor does it affect echoing of ^M. But commenting it out seems to 
; make the resize take longer to time out.
   (send-string (get-buffer-process (current-buffer)) "stty echo\n")
;    (setq telnet-count -16)
))

3 Run plink-ssh to your target host. If you get that working, all
  should be well. Find some file you own, and note its complete
  /path/to/filename.

4 Copy the following code for ange-ftp and tramp (remember that tramp
  requires ange-ftp!) to somewhere (e.g. your .emacs). Remove or modify
  whatever you see fit, but you must absolutely change:

- shell-prompt-pattern to something appropriate for your target(s).
  You might wanna try commenting it out (i.e. using the default), or
  doing a regexp that works with the prompts you have observed above.

- The string "password" to your password on the target. (This reminds
  me, I need to post about this.) Unfortunately 'plink' has
  interaction problems, so for now its gotta be in the file.

  After modification, eval for testing, or install in .emacs:

;;; ange-ftp and tramp--------------------------------------------------
(require 'ange-ftp)

(setq ange-ftp-ftp-program-name
  (concat (expand-file-name (getenv "WINDIR")) "/system32/ftp.exe")
)

; customize the temporary directory that ange-ftp uses to cache files
(setq ange-ftp-tmp-name-template 
  (concat (expand-file-name (getenv "TEMP")) "/ange-ftp")
)
(setq ange-ftp-gateway-tmp-name-template 
  (concat (expand-file-name (getenv "TEMP")) "/ange-ftp")
)

;;; tramp, formerly rcp: see 
;;; http://ls6-www.informatik.uni-dortmund.de/~grossjoh/emacs/tramp.html

; ; Daniel Pittman <[EMAIL PROTECTED]> 1/8/00 8:37:15 PM >>>
; ; > in your .emacs, make sure that you have `(require 'rcp)' /after/
; ; > `(require 'ange-ftp)'. Make sure that you *do* have the require
for
; ; > ange-ftp as well...

; (require 'rcp)
(require 'tramp)

;;; shell-prompt-pattern stuff
; I want .mycshrc to have
; set prompt="%/> "
; so use
(setq shell-prompt-pattern "^.*/ncsu/tlroche> ")

; ; following from
; ; Joe Stoy <[EMAIL PROTECTED]> 5/2/00 10:47:05 AM >>>

; for debugging
(setq tramp-verbose 10)
(setq tramp-debug-buffer t)

; (setq rcp-auto-save-directory "c:/temp")
(setq tramp-auto-save-directory "d:/temp")

; [EMAIL PROTECTED] 01 Mar 2001 23:55:50 +0100
; > [tramp-methods] _either_ have rcp-program and rcp-args, _or_ they
; > have encoding and decoding commands/functions, but never both.

; [EMAIL PROTECTED] 04 Mar 2001 12:34:20 +0100
; > Tramp is quite anal about having all kinds of method parameters.
; > Don't let any of them default to anything. Specify them all. So
; > just add (tramp-rcp-args nil) into the method spec, and you should
; > be all set. Look at the other methods so you're sure you're not
; > missing anything that should be set to nil.

(setq tramp-methods
  (append
    (list
      '("t"  ; basically ssh with mimencode
;         (tramp-connection-function  tramp-open-connection-rsh)
        (tramp-connection-function  HACKED-tramp-open-connection-rsh)
        (tramp-rsh-program          "plink")
; commenting this out annoys tramp-1.449. It should instead be nil:
;         (tramp-rcp-program          "pscp")
        (tramp-rcp-program          nil)
        (tramp-rcp-args             nil)
        (tramp-remote-sh            "/bin/sh")
        (tramp-rsh-args ; note that each word must be separate!
          (
           ; This may cause buffering problems. Note that in *shell*
           ; the verbose reports follow logout ...
;           "-v" 
           ; don't really wanna do this
           ; note that args must be separate words!
           "-pw" "password"
           "-ssh"
          ))
;        (tramp-rcp-keep-date-arg    "-p")
        (tramp-rcp-keep-date-arg    nil)
        (tramp-su-program           nil)
        (tramp-su-args              nil)
        (tramp-encoding-command     "mimencode -b")
        (tramp-decoding-command     "mimencode -u -b")
        (tramp-encoding-function    base64-encode-region)
        (tramp-decoding-function    base64-decode-region)
        (tramp-telnet-program       nil))
    )
    tramp-methods)
) ; end (setq tramp-methods

(setq tramp-default-method "t")
; calling syntax is, e.g.
; /r@t:[EMAIL PROTECTED]:.emacs

5 Do 

  M-x find-file /r@t:[EMAIL PROTECTED]:<known file from above>

  Magic should ensue. If not, post.

After things work, you might wanna

* turn off tramp-verbose and tramp-debug-buffer.

* try again with Cygwin :-) Globally, and longterm, it's the better
  solution.

HTH, [EMAIL PROTECTED]

Reply via email to