screen-users
[Top][All Lists]
Advanced

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

Re: Sending commands to shell


From: Stephane Chazelas
Subject: Re: Sending commands to shell
Date: Thu, 10 Sep 2015 20:49:58 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-09-10 15:22:05 -0400, -:
> 
> Hello, I'm fairly new to screen.
> 
> Is there a way to send a command from within an application running
> in a screen session to the shell?  For example, without leaving the
> application can I send a shell script to perform a task then return
> to the application?
[...]

It's not clear what you're asking.

In each "screen" "window", "screen" typically runs a shell. In
that shell, you may run an application. While that application
runs, the shell is just idle waiting for the application to
finish (and is not otherwise expecting any input).

screen itself is just a terminal emulator.

Now, nothing stops that application starting other commands be
them scripts, or not.

If you mean you want to run another application, specifically a
script, that runs concurrently with the application currently
running in your shell and screen window, you can do the same as
with any other terminal emulator: interrupt the "application"
with CTRL-Z, but it in background with "bg" and run the second
application ("script") in forground from your shell (or both in
background, or the script in background with "&" and then resume
your application in foreground with "fg".

Alternatively, you can run another application that shares the
screen windows with screen's "exec" command.

With ^A:exec myscript

You'd run myscript running in another pseudo-terminal, but
screen would forward the output by "myscript" to that
pseudo-terminal to your screen window, and what you type would
go instead to "myscript" (be redirected by screen to that pseudo
tty).

You can tune how the forwarding of the input/output is done by
the first argument of "exec", which can do very useful things
like have "myscript" post process the output of the applications
run in your window or pre-process your input...

See the documentation about "exec" for more details.

-- 
Stephane



reply via email to

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