Re: Initiate command in another shell session?

Liste des GroupesRevenir à cu shell 
Sujet : Re: Initiate command in another shell session?
De : zsd (at) *nospam* jdvb.ca (Jim Diamond)
Groupes : comp.unix.shell
Date : 16. Mar 2025, 19:45:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrnvte721.l4l.zsd@x360.localdomain>
References : 1 2 3 4
User-Agent : slrn/1.0.3 (Linux)
On 2025-03-13 at 15:25 ADT, Dan Cross <cross@spitfire.i.gajendra.net> wrote:
In article <vqv1c0$3gq75$1@dont-email.me>,
Janis Papanagnou  <janis_papanagnou+ng@hotmail.com> wrote:
On 13.03.2025 14:01, Dan Cross wrote:
In article <vquhba$3817f$1@dont-email.me>,
Janis Papanagnou  <janis_papanagnou+ng@hotmail.com> wrote:
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
 
I don't think I understand what you mean.  Do you mean that you
would be able to hijack a user's TTY in order to run commands on
some other system (e.g., via `ssh` or something) as them?
>
Actually that question arose after a necessary reboot of my system,
which had shown a strange effect[*] and was unusable. - I wanted to
obtain from my shell sessions some information, and since I happen
to have dozens of shell windows open in parallel - and I considered
it boring to go through all virtual windows with all it's individual
shell windows - I thought about starting that request on each window
uniquely from one shell window. That's how it started why I pondered
about the question and tried a couple things.
>
So, no; no hijack intended, no other users concerned. (I'm the only
user on my system, or so I hope.) It was at that point actually an
academical question.
>
>
I think I understand; let me paraphrase, and tell me if I'm
correct?
>
I think you're asking if you can write to a terminal device, and
have what you write be treated as input data for whatever
program is running on that tty/pty; is that right?  And then, if
that is possible, whether you can do this over the network?
>
So that, for example, if you have a terminal emulator with a
window that is running some shell process, controlled by some
pty device, you could execute a command on that computer over
the network that would get the shell running in that window
run some command?
>
If that's correct, then the answer, generally is no: you can't
do that.  If you open the pty device associated with that shell,
you're and write to it, you're really writing to the same
output that the shell process is connected to, not it's input.
>
There's no simple way to interpose onto the input stream.

If the terminal has the "feature" that you can cause it to echo back a
string (thus seen as stdin) by writing the string to the terminal and
wrapping it with the appropriate control sequence, then you can put your
data into the input stream.  (I used this a long time ago as a
counter-measure to a particular system's admin policy that if you didn't
touch the keyboard for some amount of time they would log you off the
system.  I ran a program which wrote the special string to the terminal,
and the terminal sent a char up the line, making the system think I was
entering data.)

This depends on the terminal in use, and may not satisfy your definition of
"simple".

Cheers.
                                Jim

Date Sujet#  Auteur
13 Mar 25 * Initiate command in another shell session?17Janis Papanagnou
13 Mar 25 +* Re: Initiate command in another shell session?6Dan Cross
13 Mar 25 i+- [OT] SunOS issue (historic) (was Re: Initiate command in another shell session?)1Janis Papanagnou
13 Mar 25 i`* Re: Initiate command in another shell session?4Janis Papanagnou
13 Mar 25 i `* Re: Initiate command in another shell session?3Dan Cross
14 Mar 25 i  +- Re: Initiate command in another shell session?1Janis Papanagnou
16 Mar 25 i  `- Re: Initiate command in another shell session?1Jim Diamond
13 Mar 25 +- Re: Initiate command in another shell session?1Kaz Kylheku
13 Mar 25 +- Re: Initiate command in another shell session?1David W. Hodgins
13 Mar 25 +- Re: Initiate command in another shell session?1Christian Weisgerber
14 Mar 25 +* Re: Initiate command in another shell session?6Keith Thompson
14 Mar 25 i+- Re: Initiate command in another shell session?1Kaz Kylheku
14 Mar 25 i+- Re: Initiate command in another shell session?1Dan Cross
14 Mar 25 i`* Re: Initiate command in another shell session?3Christian Weisgerber
14 Mar 25 i `* Re: Initiate command in another shell session?2Kaz Kylheku
15 Mar 25 i  `- Re: Initiate command in another shell session?1Christian Weisgerber
14 Mar 25 `- Re: Initiate command in another shell session?1Janis Papanagnou

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal