zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Stark <sstark+zsh@mailbox.org>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: monitor screen output
Date: Mon, 11 Nov 2024 22:35:03 +0100	[thread overview]
Message-ID: <vjz5x26xdeclbobje3o4or6qa7c5azmx4l7guipjwqf5kjekwt@lmzvez4765rb> (raw)
In-Reply-To: <4d7d4279-c30e-4c2d-9291-4ca985780673@eastlink.ca>


Am Montag, den 11. November 2024 um 17:45 schrieb Ray Andrews:
>All:
>
>Can zsh monitor screen output in a backgroundy sort of way?  Say I 
>have several programs that might at some time or other output some 
>message, can zsh keep an eye on the screen any time it is written to 
>and detect that message and act upon it?

If you want it to be done natively in zsh you could probably use the 
zpty module (see zshmodules(1)):

Load the module:

   $ zmodload zsh/zpty

Start top in the background. That would be your program to monitor.
It will get the handle 'top'. You may start several programs with 
different handles:

   $ zpty top top

Read from the pseudo terminal into "var" until pattern "*mutt*" was 
found:

   $ zpty -r top var "*neomutt*"

Now Start neomutt in another shell. Above command should return after a 
couple seconds and $var should contain the top output including the 
matched text.

Cancel the background process if you are done:

   $ zpty -d top


Expect is probably the saner option to use.


Sebastian


  parent reply	other threads:[~2024-11-11 21:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 16:44 Ray Andrews
2024-11-11 16:49 ` Bart Schaefer
2024-11-11 17:18   ` Ray Andrews
2024-11-11 18:13     ` Eric Pruitt
2024-11-11 21:45       ` Ray Andrews
2024-11-11 17:24   ` Josef Sachs
2024-11-11 18:01     ` Ray Andrews
2024-11-11 21:35 ` Sebastian Stark [this message]
2024-11-11 21:48   ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vjz5x26xdeclbobje3o4or6qa7c5azmx4l7guipjwqf5kjekwt@lmzvez4765rb \
    --to=sstark+zsh@mailbox.org \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).