Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.mac.system > #70914

Re: OT? using screen via ssh

From Jolly Roger <jollyroger@pobox.com>
Newsgroups comp.sys.mac.system
Subject Re: OT? using screen via ssh
Date 2015-03-11 21:08 +0000
Organization People for the Ethical Treatment of Pirates
Message-ID <cmbp6iFhvu1U1@mid.individual.net> (permalink)
References (2 earlier) <slrnmg15ld.2870.g.kreme@kreme.eternal-september.org> <mdq7lb$6ma$1@news.datemas.de> <cmbmg0Fg4rvU6@mid.individual.net> <slrnmg1aiu.2870.g.kreme@kreme.eternal-september.org> <mdqado$bip$1@news.datemas.de>

Show all headers | View raw


On 2015-03-11, Alan Baker <alangbaker@telus.net> wrote:
> On 2015-03-11 20:48:47 +0000, Lewis said:
>
>> Okay, so one time? In band camp? Jolly Roger <jollyroger@pobox.com> was 
>> all, like:
>>> On 2015-03-11, Alan Baker <alangbaker@telus.net> wrote:
>>>> On 2015-03-11 19:24:47 +0000, Lewis said:
>>>> 
>>>>> True, but it runs a different instance of bash than the one that ran
>>>>> screen in the first place.
>>>>> 
>>>>> tmux sounds interesting.
>>>> 
>>>> I don't think there is an instance of bash that ran "in the first place".
>>>> 
>>>> Straight from the Mac OS X (Mavericks/10.9.4) ssh man page:
>>>> 
>>>> " If command is specified, it is executed on the remote host INSTEAD of
>>>> a login shell."
>> 
>>> Naturally. I use screen a lot on remote computers, and it's no effort at
>>> all to first establish an ssh connection to get a shell and then run
>>> screen afterward.
>> 
>> That is probably what I will end up doing.
>
> Just add a command to execute screen in one of "~/.bash_profile", 
> "~/.bash_login", or "~/.profile".

This isn't what Lewis wants, but I have this code in my shell startup
files (.bashrc) that shows me a list of available screen sessions when I
have one or more already running during login:

#  login greeting for screen 

if [ "$TERM" = "screen" -a ! "$SHOWED_SCREEN_MESSAGE" = "true" ];
then
        echo "[ screen is currently active ]"
        export SHOWED_SCREEN_MESSAGE="true"
fi
detached_screens=`screen -list | grep Detached`
if [ ! -z "$detached_screens" ]; then
        echo ""
        echo "        Detached screens are available:"
        echo ""
        echo "        PID.TTY.HOST            STATUS"
        echo "        ----------------------------------"
        echo "$detached_screens"
        echo ""
        echo "        To reattach, type: screen -r pid.tty.host "
        echo ""
fi

The resulting output looks like this:

# ssh server
Last login: Wed Mar 11 14:07:12 2015

        Detached screens are available:

        PID.TTY.HOST            STATUS
        ----------------------------------
	37134.ttys001.server	(Detached)

        To reattach, type: screen -r pid.tty.host 
# 

Caveat: This can interfere with some utilities like sftp, rsync, etc if
they do not expect such output when they connect.

-- 
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR

Back to comp.sys.mac.system | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

OT? using screen via ssh Lewis <g.kreme@gmail.com.dontsendmecopies> - 2015-03-10 21:48 +0000
  Re: OT? using screen via ssh billy@MIX.COM - 2015-03-11 04:33 +0000
    Re: OT? using screen via ssh Jolly Roger <jollyroger@pobox.com> - 2015-03-11 14:10 +0000
    Re: OT? using screen via ssh tmo1138 <tmo1138@tmo1138.org> - 2015-03-11 15:11 -0700
  Re: OT? using screen via ssh Barry Margolin <barmar@alum.mit.edu> - 2015-03-11 12:34 -0400
    Re: OT? using screen via ssh Lewis <g.kreme@gmail.com.dontsendmecopies> - 2015-03-11 19:24 +0000
      Re: OT? using screen via ssh Alan Baker <alangbaker@telus.net> - 2015-03-11 13:13 -0700
        Re: OT? using screen via ssh Jolly Roger <jollyroger@pobox.com> - 2015-03-11 20:22 +0000
          Re: OT? using screen via ssh Lewis <g.kreme@gmail.com.dontsendmecopies> - 2015-03-11 20:48 +0000
            Re: OT? using screen via ssh Alan Baker <alangbaker@telus.net> - 2015-03-11 14:00 -0700
              Re: OT? using screen via ssh Jolly Roger <jollyroger@pobox.com> - 2015-03-11 21:08 +0000
                Re: OT? using screen via ssh Lewis <g.kreme@gmail.com.dontsendmecopies> - 2015-03-12 12:53 +0000
                Re: OT? using screen via ssh Jolly Roger <jollyroger@pobox.com> - 2015-03-12 12:57 +0000
                Re: OT? using screen via ssh Lewis <g.kreme@gmail.com.dontsendmecopies> - 2015-03-12 13:29 +0000
        Re: OT? using screen via ssh Barry Margolin <barmar@alum.mit.edu> - 2015-03-11 16:32 -0400
          Re: OT? using screen via ssh Alan Baker <alangbaker@telus.net> - 2015-03-11 13:40 -0700
      Re: OT? using screen via ssh Barry Margolin <barmar@alum.mit.edu> - 2015-03-11 16:32 -0400

csiph-web