Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: logout from interactive subshell




----- Original Message ----- From: "Christian Taylor" <cht@xxxxxxxxx>
To: <zsh-users@xxxxxxxxxx>
Sent: Thursday, October 12, 2006 6:16 AM
Subject: Re: logout from interactive subshell


A typical application would go like this:

   rlogin foobar
   DO SOME STUFF
   cleartool setview myview # this creates a subshell
   DO MORE STUFF
   cleartool setview yourview # now I'm two subshells deep
   DO STILL MORE STUFF
   # Now I want to exit
   exit
   exit
   logout

I would like to have a (interactive) command which does the final two
exits plus
a logout for me.

I don't know how to do exactly what you have in mind, but I can think of two methods that may be of use to you. Both should (usually) work independent of
which shell you use. The second is close to what you asked for.

1. Shortcut
You can hit "^D" instead of typing exit (or logout) to terminate the current
shell. If you are three subshells deep, holding Ctrl and hitting "d" three
times is quite a lot faster, but you still have to keep track of how many
subshells you want to exit.

2. Screen
After you log into the remote box, start a screen session (simply
type "screen"). Proceed to do your stuff. After you're done, hit "^A"
followed by "k". Screen will ask you to confirm and then terminates all your
subshells, as well as itself.
To logout automatically as well, I suggest you create an alias for the
command "screen; logout" and run that after login.

(Screen is capable of much more, have a look at the man page if you're
interested.)

hope this helps,
Christian

These answers come the closest to sanity in my opinion.
They don't exactly do what he wants but the fault lies in the request not in the shell or anyones knowledge of how to use it.

I'd have said there is no answer. Ultimately there is no way for any given process to know how far you mean when you say you want to log "all the way out" except it would/should be possible to say "all the way off this host" by talking to the daemon you logged in via. In fact that is possible but it's not garunteed to always work completely and there is one desireable level of control missing. (or, if what I'm about to describe is possible I hope to hear about it :)

rlogin, ssh, & telnet all support an escape character similar to classic cu.
Sometimes it's optional and not used by default, and it takes different forms between say telnet & ssh, but in some form, if desired, it's always available as an option.

In the case of ssh, On a new line (or hit enter blindly if you're terminal is messed up) type ~.
and you are disconnected from the ssh session.
sshd on the remote host then sends a HUP to all child processes of that session and in a perfect world they all react to this in a sane manner by cleaning up shop and exiting.

The problems are:
1) this isn't a perfect world and lots of apps don't die. you'll have to just try and see if you are stuck with any like that. 2) if you are connected from host to host to host, this breaks your closest connection, not your furthest one. In a perfect world again, this does end up cleanly breaking all the subsequent connections and killing all the child processes on the the whole train of hosts all in one easy shot. Maybe thats what you wanted, in which case, fine, problem solved.

But if you only want to back out of your lest leg of the chain of connections and not destroy the whole chain, I don't know how to do that except by manually specifying a different escape character or sequence for each new connection, so the the escape code for one connection gets ignored and passed along as ordinary data by all the rest.

The I think it's outside the shells area of responsibility to even attempt to keep track of such things.

Brian K. White  --  brian@xxxxxxxxx  --  http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro  BBx    Linux  SCO  FreeBSD    #callahans  Satriani  Filk!



Messages sorted by: Reverse Date, Date, Thread, Author