Re: simply preserving sessions across disconnect
Rich Boyce <rich-jcUp+/l53Jxaa/[email protected]>
| Newsgroups | gmane.comp.gnu.screen.user |
|---|---|
| Message-ID | <[email protected]> |
On 30/06/2011 19:13, Adam Kellas wrote: > On Thu, Jun 30, 2011 at 6:01 AM, Rich Boyce<rich-jcUp+/l53Jxaa/[email protected]> 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 >> fi >> fi >> >> 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. > Rich, > > 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? Rich