[Top][All Lists]

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

Reattaching to a detached screen

From: JCA
Subject: Reattaching to a detached screen
Date: Sun, 28 Dec 2008 11:02:35 +0000

    I usually run screen in conjunction with autossh. I have the
following issue:

    Occasionally, my network connection gets interrupted for whatever
reason, and I end up with one (or more) detached screen. How can I
reattach to it while keeping just one screen? Let me elaborate a bit.

    From my Linux PC (which I'll call MyPC) I start a screen in a
remote Linux PC (called RemPC) by means of the command

    xterm -bg black -fg white -fa "Lucida Mono" -fs 8 -sb -sl 1024
-rightbar -ls -e rscreen RemPC

where rscreen is a script part of the autossh package, which
essentially does the following:

   autossh -M 0 -t RemotePC "screen -e^Yy -D -R -S `uname -n`2RemotePC-$NEXT"

with NEXT being a variable that keeps track of connections from MyPC
to RemotePC. After doing this, if everything goes OK an invocation of
screen -list on RemotePC will result in an output containing a line

    xxx.MyPC2RemotePC-yyy      (Attached)

where xxx is the process number associated with that screen on
RemotePC and yyy is some integer that identifies this particular
screen among other similar ones on RemotePC.

   Now if on MyPC I close the xterm that launched this particular
screen, the output from scrren -list on RemotePC above will now read

    xxx.MyPC2RemotePC-yyy     (Detached)

What I would like to be able to do is to attach to this screen from a
new shell in RemotePC, or a new screen launched from MyPC, such that
the deattached screen now becomes attached AND the new shell or screen
disappears, with the reattached screen taking its place.

    Reattaching is easy - there are several screen options that
accomplish that. It's getting rid of the new, supporting process
(shell or screen) that I just can't pull off. Is this doable in a
simple way?

reply via email to

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