* Tramp handling of customized prompts
@ 2007-06-05 13:28 stewartbryson
[not found] ` <nqwsyi8orz.fsf@alcatel-lucent.de>
0 siblings, 1 reply; 7+ messages in thread
From: stewartbryson @ 2007-06-05 13:28 UTC (permalink / raw)
To: help-gnu-emacs
What is the best approach for handling customized input prompts from
remote shells? I tried writing a coupled regexp and function to handle
it, and put the couple in the variable tramp-actions-before-shell, but
I am not able to successfully pull the correct buffer/process, as the
required tramp functions are not available to me.
Basically, I have a screen that asks me to select a database profile
from a list. Ultimately, I would like to see that output and choose
one, but I know that's probably not possible. Always responding with a
"0" (zero) would be a viable solution, and then one I tried coding.
Thanks very much.
Stewart
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tramp handling of customized prompts
[not found] ` <nqwsyi8orz.fsf@alcatel-lucent.de>
@ 2007-06-05 16:08 ` stewartbryson
2007-06-07 21:08 ` Michael Albinus
[not found] ` <mailman.1752.1181250520.32220.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: stewartbryson @ 2007-06-05 16:08 UTC (permalink / raw)
To: help-gnu-emacs
I'm in an environment where I don't have a choice. I don't have an
individual user account on the database servers I'm connecting to, and
therefore, do not have control over the profiles there.
Any other advice with this in mind?
Thanks very much.
Stewart
On Jun 5, 10:22 am, Michael Albinus <michael.albi...@gmx.de> wrote:
> "stewartbry...@gmail.com" <stewartbry...@gmail.com> writes:
> > What is the best approach for handling customized input prompts from
> > remote shells? I tried writing a coupled regexp and function to handle
> > it, and put the couple in the variable tramp-actions-before-shell, but
> > I am not able to successfully pull the correct buffer/process, as the
> > required tramp functions are not available to me.
>
> Best would be to avoid customized prompts. Usually, $TERM is set to
> "dumb" when Tramp connects to a remote host. You shall check this
> value in your .profile/.login on the remote host, and set the prompt
> to "$ " or something like this if it matches.
>
> > Thanks very much.
>
> > Stewart
>
> Best regards, Michael.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tramp handling of customized prompts
2007-06-05 16:08 ` stewartbryson
@ 2007-06-07 21:08 ` Michael Albinus
[not found] ` <mailman.1752.1181250520.32220.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Michael Albinus @ 2007-06-07 21:08 UTC (permalink / raw)
To: stewartbryson@gmail.com; +Cc: help-gnu-emacs
"stewartbryson@gmail.com" <stewartbryson@gmail.com> writes:
> Any other advice with this in mind?
Which Tramp version do you use? Tramp 2.0 is fussy indeed for being in
the right buffer. Tramp 2.1 shall be more docile. I would try the
following code (untested):
(defvar my-tramp-prompt-regexp
(concat (regexp-opt '("Please enter a digit:") t) "\\s-*")
"Regular expression matching my database chooser prompt.")
(defun my-tramp-action (proc vec)
"Enter \"0\" in order to choose a correct database."
(save-window-excursion
(with-current-buffer (tramp-get-connection-buffer vec)
(tramp-message vec 6 "\n%s" (buffer-string))
(tramp-send-string vec "0"))))
(add-to-list 'tramp-actions-before-shell
'((my-tramp-prompt-regexp my-tramp-action)))
> Thanks very much.
>
> Stewart
Best regards, Michael.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tramp handling of customized prompts
[not found] ` <mailman.1752.1181250520.32220.help-gnu-emacs@gnu.org>
@ 2007-06-12 16:19 ` stewartbryson
2007-06-12 19:55 ` Michael Albinus
[not found] ` <mailman.2049.1181678147.32220.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: stewartbryson @ 2007-06-12 16:19 UTC (permalink / raw)
To: help-gnu-emacs
On Jun 7, 5:08 pm, Michael Albinus <michael.albi...@gmx.de> wrote:
> "stewartbry...@gmail.com" <stewartbry...@gmail.com> writes:
> > Any other advice with this in mind?
>
> Which Tramp version do you use? Tramp 2.0 is fussy indeed for being in
> the right buffer. Tramp 2.1 shall be more docile. I would try the
> following code (untested):
>
> (defvar my-tramp-prompt-regexp
> (concat (regexp-opt '("Please enter a digit:") t) "\\s-*")
> "Regular expression matching my database chooser prompt.")
>
> (defun my-tramp-action (proc vec)
> "Enter \"0\" in order to choose a correct database."
> (save-window-excursion
> (with-current-buffer (tramp-get-connection-buffer vec)
> (tramp-message vec 6 "\n%s" (buffer-string))
> (tramp-send-string vec "0"))))
>
> (add-to-list 'tramp-actions-before-shell
> '((my-tramp-prompt-regexp my-tramp-action)))
>
> > Thanks very much.
>
> > Stewart
>
> Best regards, Michael.
I upgraded to tramp 2.1.9, and invoked the following code:
(require 'tramp)
(defvar tramp-db-num-prompt-regexp (concat (regexp-opt '("Please enter
your choice:") t) "\\s-*")
"Custom regexp for interacting with the database number prompt at DS
Waters.")
(defun tramp-action-db-num-prompt (proc vec)
"Enter \"0\" in order to choose a correct database."
(save-window-excursion
(with-current-buffer (tramp-get-connection-buffer vec)
(tramp-message vec 6 "\n%s" (buffer-string))
(tramp-send-string vec "0"))))
(add-to-list 'tramp-actions-before-shell
'((tramp-db-num-prompt-regexp tramp-action-db-num-prompt)))
When I tried using tramp, I got the following error:
Wrong type argument: symbolp, (tramp-db-num-prompt-regexp tramp-action-
db-num-prompt)
Thanks Michael.
swb
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tramp handling of customized prompts
2007-06-12 16:19 ` stewartbryson
@ 2007-06-12 19:55 ` Michael Albinus
[not found] ` <mailman.2049.1181678147.32220.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Michael Albinus @ 2007-06-12 19:55 UTC (permalink / raw)
To: stewartbryson@gmail.com; +Cc: help-gnu-emacs
"stewartbryson@gmail.com" <stewartbryson@gmail.com> writes:
> I upgraded to tramp 2.1.9, and invoked the following code:
>
> (require 'tramp)
>
> (defvar tramp-db-num-prompt-regexp (concat (regexp-opt '("Please enter
> your choice:") t) "\\s-*")
> "Custom regexp for interacting with the database number prompt at DS
> Waters.")
>
> (defun tramp-action-db-num-prompt (proc vec)
> "Enter \"0\" in order to choose a correct database."
> (save-window-excursion
> (with-current-buffer (tramp-get-connection-buffer vec)
> (tramp-message vec 6 "\n%s" (buffer-string))
> (tramp-send-string vec "0"))))
>
> (add-to-list 'tramp-actions-before-shell
> '((tramp-db-num-prompt-regexp tramp-action-db-num-prompt)))
Cut'n'waste error in my example. You would need
(add-to-list 'tramp-actions-before-shell
'(tramp-db-num-prompt-regexp tramp-action-db-num-prompt))
Also, you might consider to use own symbol names _not_ starting with
"tramp-". It is common practice to apply such prefixes only to all
symbols of a package. This is useful for later debugging.
> Thanks Michael.
>
> swb
Best regards, Michael.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tramp handling of customized prompts
[not found] ` <mailman.2049.1181678147.32220.help-gnu-emacs@gnu.org>
@ 2007-06-12 20:22 ` stewartbryson
2007-06-13 4:53 ` Michael Albinus
0 siblings, 1 reply; 7+ messages in thread
From: stewartbryson @ 2007-06-12 20:22 UTC (permalink / raw)
To: help-gnu-emacs
On Jun 12, 3:55 pm, Michael Albinus <michael.albi...@gmx.de> wrote:
> "stewartbry...@gmail.com" <stewartbry...@gmail.com> writes:
> > I upgraded to tramp 2.1.9, and invoked the following code:
>
> > (require 'tramp)
>
> > (defvar tramp-db-num-prompt-regexp (concat (regexp-opt '("Please enter
> > your choice:") t) "\\s-*")
> > "Custom regexp for interacting with the database numberpromptat DS
> > Waters.")
>
> > (defun tramp-action-db-num-prompt(proc vec)
> > "Enter \"0\" in order to choose a correct database."
> > (save-window-excursion
> > (with-current-buffer (tramp-get-connection-buffer vec)
> > (tramp-message vec 6 "\n%s" (buffer-string))
> > (tramp-send-string vec "0"))))
>
> > (add-to-list 'tramp-actions-before-shell
> > '((tramp-db-num-prompt-regexp tramp-action-db-num-prompt)))
>
> Cut'n'waste error in my example. You would need
>
> (add-to-list 'tramp-actions-before-shell
> '(tramp-db-num-prompt-regexp tramp-action-db-num-prompt))
>
This worked! Thanks very much.
> Also, you might consider to use own symbol names _not_ starting with
> "tramp-". It is common practice to apply such prefixes only to all
> symbols of a package. This is useful for later debugging.
>
I took your suggestion with this as well. Any recommendations on how
to signify that these custom functions are specific for using with
Tramp, or am I looking for overkill here?
> > Thanks Michael.
>
> > swb
>
> Best regards, Michael.- Hide quoted text -
>
> - Show quoted text -
Thanks again Michael.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tramp handling of customized prompts
2007-06-12 20:22 ` stewartbryson
@ 2007-06-13 4:53 ` Michael Albinus
0 siblings, 0 replies; 7+ messages in thread
From: Michael Albinus @ 2007-06-13 4:53 UTC (permalink / raw)
To: stewartbryson@gmail.com; +Cc: help-gnu-emacs
"stewartbryson@gmail.com" <stewartbryson@gmail.com> writes:
>> Also, you might consider to use own symbol names _not_ starting with
>> "tramp-". It is common practice to apply such prefixes only to all
>> symbols of a package. This is useful for later debugging.
>
> I took your suggestion with this as well. Any recommendations on how
> to signify that these custom functions are specific for using with
> Tramp, or am I looking for overkill here?
Common practice is to use the prefix my-tramp-... or swb-tramp-... It's
obvious then for which it is intended. The byte compiler doesn't care,
but such prefixes help filtering during debugging/tracing. See example
instructions at <http://www.gnu.org/software/tramp/#Traces-and-Profiles>
> Thanks again Michael.
Best regards, Michael.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-06-13 4:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-05 13:28 Tramp handling of customized prompts stewartbryson
[not found] ` <nqwsyi8orz.fsf@alcatel-lucent.de>
2007-06-05 16:08 ` stewartbryson
2007-06-07 21:08 ` Michael Albinus
[not found] ` <mailman.1752.1181250520.32220.help-gnu-emacs@gnu.org>
2007-06-12 16:19 ` stewartbryson
2007-06-12 19:55 ` Michael Albinus
[not found] ` <mailman.2049.1181678147.32220.help-gnu-emacs@gnu.org>
2007-06-12 20:22 ` stewartbryson
2007-06-13 4:53 ` Michael Albinus
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.