unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* tramp:sshx:(screen|tmux)
@ 2014-09-09 18:38 Sam Steingold
  2014-09-10 13:55 ` tramp:sshx:(screen|tmux) Michael Albinus
  0 siblings, 1 reply; 13+ messages in thread
From: Sam Steingold @ 2014-09-09 18:38 UTC (permalink / raw)
  To: emacs-devel

Hi,
I wonder if it is possible to add a "nohup/screen/tmux" method which
would create a remote screen/tmux session or reconnect to it if it
already exists.
The idea is that some interactions (e.g., an interactive R session) is
too expensive to restore after a crash caused by a disconnect.

(see also
http://stackoverflow.com/questions/16819248/emacs-tramp-over-an-unreliable-connection)

Thanks.
-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://think-israel.org http://ffii.org
http://jihadwatch.org http://dhimmi.org http://thereligionofpeace.com
If you want to shoot yourself, it is YOUR responsibility to wear armor.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-09 18:38 tramp:sshx:(screen|tmux) Sam Steingold
@ 2014-09-10 13:55 ` Michael Albinus
  2014-09-10 14:12   ` tramp:sshx:(screen|tmux) joakim
  2014-09-10 15:06   ` tramp:sshx:(screen|tmux) Sam Steingold
  0 siblings, 2 replies; 13+ messages in thread
From: Michael Albinus @ 2014-09-10 13:55 UTC (permalink / raw)
  To: Sam Steingold; +Cc: emacs-devel

Sam Steingold <sds@gnu.org> writes:

> Hi,

Hi Sam,

> I wonder if it is possible to add a "nohup/screen/tmux" method which
> would create a remote screen/tmux session or reconnect to it if it
> already exists.
> The idea is that some interactions (e.g., an interactive R session) is
> too expensive to restore after a crash caused by a disconnect.

A while ago, I've played with mosh(*) as Tramp connection method. It is
designed exactly for your case, supporting reconnection of lost
sessions. I failed, because mosh is designed to draw on a screen, which
is not what Tramp needs in a connection buffer.

Your idea to reconnect to an existing screen / tmux session would suffer
from the same problem I guess. At least I'm not aware how to support
them in an Emacs buffer.

(*): https://mosh.mit.edu/

> Thanks.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 13:55 ` tramp:sshx:(screen|tmux) Michael Albinus
@ 2014-09-10 14:12   ` joakim
  2014-09-10 15:09     ` tramp:sshx:(screen|tmux) Sam Steingold
  2014-09-11  0:22     ` tramp:sshx:(screen|tmux) Svend Sorensen
  2014-09-10 15:06   ` tramp:sshx:(screen|tmux) Sam Steingold
  1 sibling, 2 replies; 13+ messages in thread
From: joakim @ 2014-09-10 14:12 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Sam Steingold, emacs-devel

Michael Albinus <michael.albinus@gmx.de> writes:

> Sam Steingold <sds@gnu.org> writes:
>
>> Hi,
>
> Hi Sam,
>
>> I wonder if it is possible to add a "nohup/screen/tmux" method which
>> would create a remote screen/tmux session or reconnect to it if it
>> already exists.
>> The idea is that some interactions (e.g., an interactive R session) is
>> too expensive to restore after a crash caused by a disconnect.
>
> A while ago, I've played with mosh(*) as Tramp connection method. It is
> designed exactly for your case, supporting reconnection of lost
> sessions. I failed, because mosh is designed to draw on a screen, which
> is not what Tramp needs in a connection buffer.
>
> Your idea to reconnect to an existing screen / tmux session would suffer
> from the same problem I guess. At least I'm not aware how to support
> them in an Emacs buffer.
>
> (*): https://mosh.mit.edu/
>
>> Thanks.
>
> Best regards, Michael.
>

I have used dtach for this, albeit in a slightly different context.
Maybe dtach can be of use for tramp?

http://dtach.sourceforge.net/

-- 
Joakim Verona



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 13:55 ` tramp:sshx:(screen|tmux) Michael Albinus
  2014-09-10 14:12   ` tramp:sshx:(screen|tmux) joakim
@ 2014-09-10 15:06   ` Sam Steingold
  2014-09-10 17:56     ` tramp:sshx:(screen|tmux) Michael Albinus
  2014-09-11 19:41     ` tramp:sshx:(screen|tmux) David Caldwell
  1 sibling, 2 replies; 13+ messages in thread
From: Sam Steingold @ 2014-09-10 15:06 UTC (permalink / raw)
  To: emacs-devel

Hi Michael,

> * Michael Albinus <zvpunry.nyovahf@tzk.qr> [2014-09-10 15:55:53 +0200]:
> Sam Steingold <sds@gnu.org> writes:
>
>> I wonder if it is possible to add a "nohup/screen/tmux" method which
>> would create a remote screen/tmux session or reconnect to it if it
>> already exists.
>> The idea is that some interactions (e.g., an interactive R session) is
>> too expensive to restore after a crash caused by a disconnect.
>
> A while ago, I've played with mosh(*) as Tramp connection method. It
> is designed exactly for your case, supporting reconnection of lost
> sessions. I failed, because mosh is designed to draw on a screen,
> which is not what Tramp needs in a connection buffer.
> 
> Your idea to reconnect to an existing screen / tmux session would
> suffer from the same problem I guess. At least I'm not aware how to
> support them in an Emacs buffer.

I am painfully aware of this problem :-(
This is way my code which I posted to the linked article on
StackOverflow passes "-c /dev/null" to screen and also runs it in emacs
terminal.

However, emacs is sufficiently heavy weight (socially) that you (as the
tramp maintainer) can ask the screen (and tmux and mosh) maintainers to
add the "-emacs" option which will disable all terminal drawing.

Thanks!

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://dhimmi.org http://mideasttruth.com
http://truepeace.org http://www.memritv.org http://ffii.org http://memri.org
A bullet affects the way the brain functions even when it hits the butt.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 14:12   ` tramp:sshx:(screen|tmux) joakim
@ 2014-09-10 15:09     ` Sam Steingold
  2014-09-10 18:06       ` tramp:sshx:(screen|tmux) Michael Albinus
  2014-09-11  0:22     ` tramp:sshx:(screen|tmux) Svend Sorensen
  1 sibling, 1 reply; 13+ messages in thread
From: Sam Steingold @ 2014-09-10 15:09 UTC (permalink / raw)
  To: emacs-devel

> *  <wbnxvz@ireban.fr> [2014-09-10 16:12:58 +0200]:
> Michael Albinus <michael.albinus@gmx.de> writes:
>> Sam Steingold <sds@gnu.org> writes:
>>
>>> I wonder if it is possible to add a "nohup/screen/tmux" method which
>>> would create a remote screen/tmux session or reconnect to it if it
>>> already exists.
>>> The idea is that some interactions (e.g., an interactive R session) is
>>> too expensive to restore after a crash caused by a disconnect.
>>
>> (*): https://mosh.mit.edu/
>
> I have used dtach for this, albeit in a slightly different context.
> Maybe dtach can be of use for tramp?
>
> http://dtach.sourceforge.net/

dtach looks like abandonware - no releases in 6 years.
However, if it is small and simple enough, the emacs community might
strip it down and take over it and ship it with emacs.

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://ffii.org http://palestinefacts.org
http://thereligionofpeace.com http://honestreporting.com http://truepeace.org
When we break the law, they fine us, when we comply, they tax us.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 15:06   ` tramp:sshx:(screen|tmux) Sam Steingold
@ 2014-09-10 17:56     ` Michael Albinus
  2014-09-10 18:37       ` tramp:sshx:(screen|tmux) Stefan Monnier
  2014-09-11 19:41     ` tramp:sshx:(screen|tmux) David Caldwell
  1 sibling, 1 reply; 13+ messages in thread
From: Michael Albinus @ 2014-09-10 17:56 UTC (permalink / raw)
  To: Sam Steingold; +Cc: emacs-devel

Sam Steingold <sds@gnu.org> writes:

> Hi Michael,

Hi Sam,

> However, emacs is sufficiently heavy weight (socially) that you (as the
> tramp maintainer) can ask the screen (and tmux and mosh) maintainers to
> add the "-emacs" option which will disable all terminal drawing.

I have asked on the mosh ML, see
<http://thread.gmane.org/gmane.network.mosh.devel/112>. No success.

> Thanks!

Best regards, Michael.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 15:09     ` tramp:sshx:(screen|tmux) Sam Steingold
@ 2014-09-10 18:06       ` Michael Albinus
  2014-09-10 18:42         ` tramp:sshx:(screen|tmux) Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Albinus @ 2014-09-10 18:06 UTC (permalink / raw)
  To: Sam Steingold; +Cc: emacs-devel

Sam Steingold <sds@gnu.org> writes:

>> *  <wbnxvz@ireban.fr> [2014-09-10 16:12:58 +0200]:
>> Michael Albinus <michael.albinus@gmx.de> writes:
>>> Sam Steingold <sds@gnu.org> writes:
>>>
>>>> I wonder if it is possible to add a "nohup/screen/tmux" method which
>>>> would create a remote screen/tmux session or reconnect to it if it
>>>> already exists.
>>>> The idea is that some interactions (e.g., an interactive R session) is
>>>> too expensive to restore after a crash caused by a disconnect.
>>>
>>> (*): https://mosh.mit.edu/
>>
>> I have used dtach for this, albeit in a slightly different context.
>> Maybe dtach can be of use for tramp?
>>
>> http://dtach.sourceforge.net/
>
> dtach looks like abandonware - no releases in 6 years.
> However, if it is small and simple enough, the emacs community might
> strip it down and take over it and ship it with emacs.

Well, looking at screen, tmux and dtach, the latter one looks like the
most promising one. The man page claims "it works best with full-screen
applications such as emacs" :-)

All of them need some book-keeping of available sessions. This is a task
which shall be done in general for Emacs (if we decide to use them). I
have no idea, whether there is already a common Emacs package dedicated
to this.

OTOH, I believe that mosh would be better suited, because it does not
need to know about pending sessions. A simple (re-)connect to the server
in question would do the job.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 17:56     ` tramp:sshx:(screen|tmux) Michael Albinus
@ 2014-09-10 18:37       ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-09-10 18:37 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Sam Steingold, emacs-devel

> I have asked on the mosh ML, see
> <http://thread.gmane.org/gmane.network.mosh.devel/112>. No success.

No big surprise: Mosh is really designed around the idea of
synchronizing two terminal screens (the local one you see on your
display, and a remote one which is not displayed anywhere).


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 18:06       ` tramp:sshx:(screen|tmux) Michael Albinus
@ 2014-09-10 18:42         ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-09-10 18:42 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Sam Steingold, emacs-devel

>>> http://dtach.sourceforge.net/
>> dtach looks like abandonware - no releases in 6 years.
>> However, if it is small and simple enough, the emacs community might
>> strip it down and take over it and ship it with emacs.

It's also the only one whose purpose is to do just what we need:
no terminal emulator madness to circumvent.


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 14:12   ` tramp:sshx:(screen|tmux) joakim
  2014-09-10 15:09     ` tramp:sshx:(screen|tmux) Sam Steingold
@ 2014-09-11  0:22     ` Svend Sorensen
  2015-05-07 13:33       ` tramp:sshx:(screen|tmux) Sam Steingold
  1 sibling, 1 reply; 13+ messages in thread
From: Svend Sorensen @ 2014-09-11  0:22 UTC (permalink / raw)
  To: emacs-devel

joakim@verona.se writes:

 > Michael Albinus <michael.albinus@gmx.de> writes:
>
> I have used dtach for this, albeit in a slightly different context.
> Maybe dtach can be of use for tramp?

I use the following function to start a remote shell running dtach.

(defun ssh-dtach (host)
  "Open SSH connection to HOST and start dtach session."
  (interactive (list (ssh-host-completing-read)))
  (let ((explicit-shell-file-name "dtach")
        (explicit-dtach-args '("-A" "/tmp/emacs.dtach" "-z"
                               "/bin/bash" "--noediting" "-login"))
        (default-directory (format  "/ssh:%s:" host)))
    (shell (format "*ssh %s*" host))))




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-10 15:06   ` tramp:sshx:(screen|tmux) Sam Steingold
  2014-09-10 17:56     ` tramp:sshx:(screen|tmux) Michael Albinus
@ 2014-09-11 19:41     ` David Caldwell
  2014-09-11 20:26       ` tramp:sshx:(screen|tmux) Michael Albinus
  1 sibling, 1 reply; 13+ messages in thread
From: David Caldwell @ 2014-09-11 19:41 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1313 bytes --]

On 9/10/14 8:06 AM, Sam Steingold wrote:

> However, emacs is sufficiently heavy weight (socially) that you (as the
> tramp maintainer) can ask the screen (and tmux and mosh) maintainers to
> add the "-emacs" option which will disable all terminal drawing.

Tmux has the relatively unknown -C option which puts it into command
mode. Here's what it looks like:

$ tmux -C attach
%begin 1410464037 1 0
%end 1410464037 1 0
%session-changed $0 0
%layout-change @0 b25d,80x24,0,0,0
%layout-change @1 b25e,80x24,0,0,1
%layout-change @2 b25f,80x24,0,0,2
%layout-change @3 b260,80x24,0,0,3
send-keys "echo hello\n"
%begin 1410464043 2 1
%end 1410464043 2 1
%output %0 \015\033[K\033]0;david@death:
~\007\033[01;32mdavid@death\033[00m:\033[01;34m~\033[00m$ echo
hello\015\012hello\015\012
%output %0 \033]0;david@death:
~\007\033[01;32mdavid@death\033[00m:\033[01;34m~\033[00m$
detach-client
%begin 1410464047 3 1
%end 1410464047 3 1

Lines starting with a % are from tmux, the "send-keys" and
"detach-client" are commands I sent to it.

Though I suspect for the purposes you want, there's still too much
terminal nonsense going on--tmux command mode just lets you get to the
heart of tmux, but input and output to the processes it controls is
still very terminal oriented.

-David


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4219 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-11 19:41     ` tramp:sshx:(screen|tmux) David Caldwell
@ 2014-09-11 20:26       ` Michael Albinus
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Albinus @ 2014-09-11 20:26 UTC (permalink / raw)
  To: David Caldwell; +Cc: emacs-devel

David Caldwell <david@porkrind.org> writes:

> On 9/10/14 8:06 AM, Sam Steingold wrote:
>
>> However, emacs is sufficiently heavy weight (socially) that you (as the
>> tramp maintainer) can ask the screen (and tmux and mosh) maintainers to
>> add the "-emacs" option which will disable all terminal drawing.
>
> Tmux has the relatively unknown -C option which puts it into command
> mode. Here's what it looks like:

Thanks all you guys. I'll try dtach and tmux; let's see how far I could
go. But it will need spare time, which I don't own too much these days :-(

> -David

Best regards, Michael.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: tramp:sshx:(screen|tmux)
  2014-09-11  0:22     ` tramp:sshx:(screen|tmux) Svend Sorensen
@ 2015-05-07 13:33       ` Sam Steingold
  0 siblings, 0 replies; 13+ messages in thread
From: Sam Steingold @ 2015-05-07 13:33 UTC (permalink / raw)
  To: emacs-devel; +Cc: Vitalie Spinu

> * Svend Sorensen <firaq@pvssre.arg> [2014-09-10 17:22:51 -0700]:
>
> joakim@verona.se writes:
>
>  > Michael Albinus <michael.albinus@gmx.de> writes:
>>
>> I have used dtach for this, albeit in a slightly different context.
>> Maybe dtach can be of use for tramp?
>
> I use the following function to start a remote shell running dtach.
>
> (defun ssh-dtach (host)
>   "Open SSH connection to HOST and start dtach session."
>   (interactive (list (ssh-host-completing-read)))
>   (let ((explicit-shell-file-name "dtach")
>         (explicit-dtach-args '("-A" "/tmp/emacs.dtach" "-z"
>                                "/bin/bash" "--noediting" "-login"))
>         (default-directory (format  "/ssh:%s:" host)))
>     (shell (format "*ssh %s*" host))))

It turned out that dtach does indeed do what I need:

http://stackoverflow.com/questions/16819248/emacs-tramp-over-an-unreliable-connection
(defvar R-remote-host "remote-server")
(defvar R-remote-session "R")
(defun R-remote (&optional remote-host session)
  "Connect to the remote-host's dtach session running R."
  (interactive (list
                (read-from-minibuffer "R remote host: " R-remote-host)
                (read-from-minibuffer "R remote session: " R-remote-session)))
  (pop-to-buffer (make-comint (concat "remote-" session)
                              "ssh" nil "-t" "-t" remote-host
                              "dtach" "-A" (concat ".dtach-" session)
                              "-z" "-E" "-r" "none"
                              inferior-R-program-name "--no-readline"
                              inferior-R-args))
  (ess-remote (process-name (get-buffer-process (current-buffer))) "R")
  (setq comint-process-echoes t))



-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1347
http://www.childpsy.net/ http://memri.org http://mideasttruth.com
http://thereligionofpeace.com http://www.memritv.org http://think-israel.org
Democrats, get out of my wallet! Republicans, get out of my bedroom!




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-05-07 13:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09 18:38 tramp:sshx:(screen|tmux) Sam Steingold
2014-09-10 13:55 ` tramp:sshx:(screen|tmux) Michael Albinus
2014-09-10 14:12   ` tramp:sshx:(screen|tmux) joakim
2014-09-10 15:09     ` tramp:sshx:(screen|tmux) Sam Steingold
2014-09-10 18:06       ` tramp:sshx:(screen|tmux) Michael Albinus
2014-09-10 18:42         ` tramp:sshx:(screen|tmux) Stefan Monnier
2014-09-11  0:22     ` tramp:sshx:(screen|tmux) Svend Sorensen
2015-05-07 13:33       ` tramp:sshx:(screen|tmux) Sam Steingold
2014-09-10 15:06   ` tramp:sshx:(screen|tmux) Sam Steingold
2014-09-10 17:56     ` tramp:sshx:(screen|tmux) Michael Albinus
2014-09-10 18:37       ` tramp:sshx:(screen|tmux) Stefan Monnier
2014-09-11 19:41     ` tramp:sshx:(screen|tmux) David Caldwell
2014-09-11 20:26       ` tramp:sshx:(screen|tmux) Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).