LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-15-2003, 03:55 AM   #1
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
emacs and ssh forwarding


i found the following code from a site but i just could not found a way to use it to forward my ports within emacs does any one got a idea to use this code to automate forwarding from emacs.

;;; sshfwd.el -- emacs lisp for port forwarding via ssh
;; Copyright (C) 1999 Mark Plaksin
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 2
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;

;;; Port forwarding requires passive ftp, so this command should
;;; invoke a program that is passive ftp. On Linux, "pftp" is
;;; passive.
(setq ange-ftp-ftp-program-name "pftp")

(defvar map-ssh-program "ssh" "Name of ssh program.")

(defun map-ssh-port-forward (localport host remoteport)
"Sets up ssh port forwarding.
Assumes map-ssh-program points to ssh binary."
(let* ((procname (concat localport ":" host ":" remoteport))
(buffname (concat "*" procname "*"))
(port-string (concat localport ":" host ":" remoteport)))
;; If buffname exists, assume forwarding is already set up.
(if (get-buffer buffname)
(message (concat "Forwarding already set up for " procname "."))
(start-process procname buffname map-ssh-program "-C" "-L"
port-string host "perl -e 'while(getppid > 1){sleep 30}'")
(set-process-filter (get-process procname) 'map-ssh-filter))))

(defun map-ssh-filter (proc string)
"Prompts for password when STRING matches \".* password: $\".
Sends the password to PROC. It has only been tested with ssh and does not
handle killed buffers properly."

;; This part stolen from the Emacs Lisp docs
(with-current-buffer (process-buffer proc)
(let ((moving (= (point) (process-mark proc))))

(save-excursion
;; Insert the text, advancing the process marker.
(goto-char (process-mark proc))
(insert string)
(set-marker (process-mark proc) (point)))
(if moving (goto-char (process-mark proc)))

;; map's part starts here

;; Useful for debugging
;;(message string)

(if (string-match ".* password: $" string)
(process-send-string
proc
(concat
(read-passwd string)
"\n"))))))
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH X forwarding krusty_lab AIX 10 01-02-2008 10:36 AM
SSH X forwarding djgerbavore Linux - Networking 1 11-17-2005 10:40 AM
X forwarding via SSH bd1308 Linux - Software 4 08-30-2005 08:13 PM
Shell mode & ssh in emacs phuna Linux - Software 1 08-03-2005 05:37 PM
ssh and X-forwarding Björneborg Linux - Networking 2 02-19-2004 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration