[Top][All Lists]

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

Re: simply preserving sessions across disconnect

From: Rich Boyce
Subject: Re: simply preserving sessions across disconnect
Date: Thu, 30 Jun 2011 20:35:21 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20110303 Thunderbird/3.1.9

On 30/06/2011 19:13, Adam Kellas wrote:
On Thu, Jun 30, 2011 at 6:01 AM, Rich Boyce<address@hidden>  wrote:
That's precisely how I use screen. The way I do it is to have a snippet in
my bash login script which tests whether the scripts is running in screen
already, and if not runs 'screen -RR':

if [ ! $WINDOW ] ; then   # we're not already in screen
        if [ -e `which screen` ]; then  # we've got screen available
                screen -RR       # reattach to first available session
                exit             # logout when finished

Note that I'm working in a networked environment where my home area is the
same on my local workstation and all the servers I connect to.

That works just how you're describing what you want. It's transparent during
normal use, but if the connection to the remote server is lost then the
session is restored upon reconnect.

I'd be happy with a solution like this but can't see how it would work
for me. How could $WINDOW ever be set at initial login?
It isn't, which is why screen gets launched. The ! means 'not' - so the initial 'if' is equivalent to 'if there is no $WINDOW variable'. Screen then launches (and sets $WINDOW), which starts another instance of bash, which runs this login script. This time, since $WINDOW is not false, another screen is not launched and instead I can use the bash session.

All this only works if you put it in your login script, probably .bashrc would work for you. Perhaps that's where the trouble's coming from: you're asking Putty to run the screen command but maybe it would work better if that was handled by your login script?


reply via email to

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