help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: telnet in buffer using elisp -- is this the best way?


From: Kin Cho
Subject: Re: telnet in buffer using elisp -- is this the best way?
Date: 10 Jul 2004 15:24:50 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

"Tennis Smith" <address@hidden> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]