From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kin Cho Newsgroups: gmane.emacs.help Subject: Re: telnet in buffer using elisp -- is this the best way? Date: 10 Jul 2004 15:24:50 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <7i8ydrzej1.fsf@neoscale.com> References: <1089484878.512760@sj-nntpcache-5> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1089498485 19092 80.91.224.253 (10 Jul 2004 22:28:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 10 Jul 2004 22:28:05 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jul 11 00:27:56 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BjQK3-0006Tj-00 for ; Sun, 11 Jul 2004 00:27:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BjQMI-0000iV-IL for geh-help-gnu-emacs@m.gmane.org; Sat, 10 Jul 2004 18:30:14 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!fr.ip.ndsoftware.net!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help Original-Followup-To: gnu.emacs.help Original-Lines: 67 Original-X-Trace: news.uni-berlin.de Q4494QdGgryFHc3NYs63HA5l3LjO2I4k6cx9IefIEiACxV7k1V User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu comp.emacs:85386 gnu.emacs.help:124229 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:19562 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19562 "Tennis Smith" writes: > Hi > > Apologies for the basic nature of the questions, but my area is s/w testing, > not elisp writing. ;-) I doubt anybody's area is elisp writing -- except for the full-time emacs people at gnu. > I frequently have the need to telnet into routers, via console ports thru a > term server or a native ip address. I've built some *very* basic elisp > functions for doing this, but I'm wondering if there is a better way. The > number of routers in my environment continues to grow (Im in a testing > group, we have hundreds of the things). So, this approach has become a real > problem since each router requires a separate function to access it. > > Here are a couple examples: > > (defun 5gw-con () > (interactive) > (telnet "10.10.10.58 2008") > (rename-buffer "ef-gw-5-con")) > > (defun 5gw-con2 () > (interactive) > (telnet "10.10.10.58 2009") > (rename-buffer "ef-gw-5-con")) > > (defun 7gw () > (interactive) > (telnet "10.10.10.40") > (rename-buffer "ef-gw-7")) The code below creates these functions based on a table: (mapc (lambda (x) (fset (car x) (list 'lambda () (nth 1 x) '(interactive) (nth 1 x) `(telnet ,(nth 1 x)) `(rename-buffer ,(nth 2 x))))) '((5gw-con "10.10.10.58 2008" "ef-gw-5-con") (5gw-con2 "10.10.10.58 2009" "ef-gw-5-con2") (7gw "10.10.10.40" "ef-gw-7"))) You should M-: (info " (elisp) Top") if you want to find out how the above works. -kin > > There's an additional issue too. Sometimes the same address will be used in > multiple places. Note that the first two examples uses an ip/port > combination. In this case the port will be changing, but the base ip address > will stay the same. Is there a way to specify the ip address in _one_ place > and have it be used in multiple places? > > Is there a better way to do all this? > > TIA, > -Tennis > > > > > -- > Remove "-remove-to-reply" to respond to my email address directly.