<<< Date Index >>>     <<< Thread Index >>>

Re: piping messages to external scripts



On 2008-03-19, Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx> wrote:
> On Wednesday, March 19 at 05:08 PM, quoth Kyle Wheeler:
> > Eh? The new process remains in control of the terminal as long as it 
> > wants (i.e. it can't give up control at any point). Here's the thing, 
> > though: when you pipe a message to a script, you're filling the 
> > standard input with the *message*. If you use typical shell prompting 
> > mechanisms, they'll all try to pull from standard input, which will 
> > either be the message or will be *closed* because you already slurped 
> > it up with something. So, you can't use standard input.
> 
> What I meant to add here, but forgot, is that if you DO use standard 
> input, it will appear as though your script ran very quickly and then 
> lost control of the terminal.

Yes, you can have the script read user input from standard 
input--you just have to manage it.  For example, I have a script 
that uses perl to extract a URL from the body of the piped message, 
then uses this command to connect the script's stdin to the 
controlling terminal,

   exec < /dev/tty

then runs the w3m browser with the extracted URL.

The exec command isn't actually required by w3m, but it is needed by 
vim if I launch vim from w3m.

Regards,
Gary