Re: piping messages to external scripts
- To: mutt-users@xxxxxxxx
- Subject: Re: piping messages to external scripts
- From: Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx>
- Date: Wed, 19 Mar 2008 17:08:55 -0500
- Comment: DomainKeys? See http://domainkeys.sourceforge.net/
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=memoryhole.net; h=date: from:to:subject:message-id:references:mime-version:content-type: content-transfer-encoding:in-reply-to; q=dns/txt; s=default; bh= kTrda3tPzROSVIFxAevWTs1/mSg=; b=fAYkiIKsagsfwZSBrPkCGMpmkJ70pl7x ZWrDQiuZNcybNfDb3tpAqMN31yDsSnfKhuqAb2+WGdMQUwzJfmSja8FWF7l9DV9s Z11OMVctn0FtkTQPh2DpwxirvHFThEt6spOprR9+l6UAucEghcCDAHPmv78DYbKM k2a0B+YS/uo=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=memoryhole.net; b=Qp5K93Hlv4JP4Fhgj4GnrjB10bzi5EzqQ/w6Gc+q4aZX8Pwv3WzFZYyCqvEVuDHiwIRHUNl2S19uEt/xot6NMCFH+sESVipWjrHy9wq4sCWJixvoSAV8dPoK0J+QVdTkENkZ7+ed8JMdJH6rkEzsvM83OM/8vpvlflXNUc5mXuo=; h=Received:Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:Content-Transfer-Encoding:In-Reply-To:OpenPGP:User-Agent;
- In-reply-to: <20080319212243.GA9033@pcbsd>
- List-post: <mailto:mutt-users@mutt.org>
- List-unsubscribe: send mail to majordomo@mutt.org, body only "unsubscribe mutt-users"
- Mail-followup-to: mutt-users@xxxxxxxx
- Openpgp: id=CA8E235E; url=http://www.memoryhole.net/~kyle/kyle-pgp.asc; preference=signencrypt
- References: <20080319212243.GA9033@pcbsd>
- Sender: owner-mutt-users@xxxxxxxx
- User-agent: Mutt/1.5.17 (2008-02-27)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday, March 19 at 02:22 PM, quoth Culley Harrelson:
> I am ready to tackle this problem but when you pipe a message to a
> script it looks like a new process is spawned and the new process
> can't remain in control of the terminal. Can anyone point me in the
> right direction to make this happen?
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.
Of course, without stdin, the question becomes: how do you get user
input? You have to use something more entertaining, like the curses
library. There's a handy utility that makes this sort of thing easy
from a shell script (or any other kind of script) called "dialog". You
can then do things like:
#!/bin/sh
tmp=`mktemp -t menubox.XXXX`
dialog --menu "choose wisely" 0 0 0 \
1 'pick me' \
2 'no, really, pick me!' \
3 'forget those losers' \
4 'PICK ME!' 2>$tmp
read choice <$tmp
echo you picked $choice | less
Read dialog's documentation for all the other neat tricks you can do
with it---it's surprisingly powerful.
I'm sure there is probably a perl module out there that will do the
same thing.
~Kyle
- --
We will be a better country when each religious group can trust its
members to obey the dictates of their own religious faith without
assistance from the legal structure of their country.
-- Margaret Mead
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iEYEARECAAYFAkfhjvcACgkQBkIOoMqOI17JhACaA2CcXmEPXQmUYsFMAR+I/o34
YswAoI+HIuWcM/LlZAOvG5J7kGcZyJSv
=b7hp
-----END PGP SIGNATURE-----