Howto run a command in message hooks (was: Re: How to send a return receipt)
Hi, as it does not seem to be integrated into mutt upstream (at least not in a forseeable timeline) I'm currently trying to figure who a scripted solution to my problem would look like. On Tue, Oct 23, 2007 at 06:14:48PM +0200, Rado S wrote: It appears complex to you, but in fact it _is_ simple. If thats true, then the problem I am currently stuck on should be fairly simple to solve. So some explanations, then my question: I want to write a script that _asks_ the user, if he wants to send a return receipt (note how that differs from your assumption that a macro would be suffice. For me it wouldn't because w/o the question _I_ would forget to send the return receipt). Something like this can automatically be triggered only by message hooks. But as the solution is extern (= a script), how do i call it from within the message hook? I added a hook like this: message-hook ~h Return-Receipt-To: |/home/schoenfeld/.mutt/return_receipt And even though the specified file is a valid executable script mutt says (when I open this mail in the pager): |/home/schoenfeld/.mutt/return_receipt: Unknown command Why? According to what I read this works for macros, why shouldn't it work for message hooks? Regards Patrick
Re: Howto run a command in message hooks (was: Re: How to send a return receipt)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * Patrick Schoenfeld [EMAIL PROTECTED] [10-24-07 10:42]: I want to write a script that _asks_ the user, if he wants to send a return receipt (note how that differs from your assumption that a macro would be suffice. For me it wouldn't because w/o the question _I_ would forget to send the return receipt). Something like this can automatically be triggered only by message hooks. But as the solution is extern (= a script), how do i call it from within the message hook? I added a hook like this: message-hook ~h Return-Receipt-To: |/home/schoenfeld/.mutt/return_receipt And even though the specified file is a valid executable script mutt says (when I open this mail in the pager): |/home/schoenfeld/.mutt/return_receipt: Unknown command first *guess* w/b that ~/.mutt/return_receipt script was not executable, but you have really presented little information. - -- Patrick Shanahan Plainfield, Indiana, USAHOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535@ http://counter.li.org -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.4-svn4472 (GNU/Linux) iD8DBQFHH1sdClSjbQz1U5oRAoShAJ0RkvztBrLo1jW8fqfKCWtR1EgaaQCgpm9x 7rhYW+Z8Cfdy2Tku3GQovZU= =uIe1 -END PGP SIGNATURE-
Re: Howto run a command in message hooks (was: Re: How to send a
On Wed, Oct 24, 2007 at 10:47:58AM -0400, Patrick Shanahan wrote: * Patrick Schoenfeld [EMAIL PROTECTED] [10-24-07 10:42]: And even though the specified file is a valid executable script mutt says (when I open this mail in the pager): first *guess* w/b that ~/.mutt/return_receipt script was not Whats so hard to understand about .. is a valid executable script .. ? executable, but you have really presented little information. What information do you expect me to presentate? Eventually my whole mutt configuration just to ask why one specific message-hook (which I presentated) is not working? -Patrick
Re: Howto run a command in message hooks
On Wed, Oct 24, 2007 at 04:40:33PM +0200, Patrick Schoenfeld wrote: message-hook ~h Return-Receipt-To: |/home/schoenfeld/.mutt/return_receipt And even though the specified file is a valid executable script mutt says (when I open this mail in the pager): |/home/schoenfeld/.mutt/return_receipt: Unknown command I don't think there is a mutt command called |/home/schoenfeld/.mutt/return_receipt. Maybe you wanted the push command? -- Dave Evans http://djce.org.uk/ http://djce.org.uk/pgpkey signature.asc Description: Digital signature
Re: Howto run a command in message hooks (was: Re: How to send a
On Wed, Oct 24, 2007 at 04:53:23PM +0200, Patrick Schoenfeld wrote: What information do you expect me to presentate? Eventually my whole mutt configuration just to ask why one specific message-hook (which I presentated) is not working? There is only one information that I see that I really missed to presentate: [EMAIL PROTECTED] ~ % mutt -v Mutt 1.5.16 (2007-06-11) -Patrick
Re: Howto run a command in message hooks
Hi Christian, On Wed, Oct 24, 2007 at 04:56:13PM +0200, Christian Brabandt wrote: Do you mind formating your message with a width 80 chars? no, thats no problem. Depending on what your want try either shell-escape or pipe-message Hm. That and what Dave Evans wrote works, at least partially. Now the script is launched, but it does not work as expected. It starts the script which outputs: User has asked for a return receipt. Send one? ([yes]/no): and waits for an input (read yn), but mutt adds its Press any key to continue So it seems that mutt already answers the question (what it shouldn't do). Also if I do press return to that question, it restarts the script and the game starts from the beginning. Endless, until i somehow force it to quit (not that easy). The (for now very basic script): #!/bin/sh TEMP=`mktemp` trap rm -f $TEMP INT ABRT EXIT tee $TEMP QUESTION=User has asked for a return receipt. Send one? ([yes]/no): echo -n $QUESTION read yn (I know that this is far from beeing complete, but to test how things would work it is enough) Any hints? Regards, Patrick
Re: Howto run a command in message hooks
Hi Patrick! Do you mind formating your message with a width 80 chars? On Wed, 24 Oct 2007, Patrick Schoenfeld wrote: I want to write a script that _asks_ the user, if he wants to send a return receipt (note how that differs from your assumption that a macro would be suffice. For me it wouldn't because w/o the question _I_ would forget to send the return receipt). Something like this can automatically be triggered only by message hooks. But as the solution is extern (= a script), how do i call it from within the message hook? I added a hook like this: message-hook ~h Return-Receipt-To: |/home/schoenfeld/.mutt/return_receipt And even though the specified file is a valid executable script mutt says (when I open this mail in the pager): |/home/schoenfeld/.mutt/return_receipt: Unknown command Depending on what your want try either shell-escape or pipe-message regards, Christian -- f y cn rd ths thn y cn hv grt jb n cmptr prgrmmng
Re: Howto run a command in message hooks
Hi Patrick! On Wed, 24 Oct 2007, Patrick Schoenfeld wrote: On Wed, Oct 24, 2007 at 04:56:13PM +0200, Christian Brabandt wrote: Do you mind formating your message with a width 80 chars? no, thats no problem. Depending on what your want try either shell-escape or pipe-message Hm. That and what Dave Evans wrote works, at least partially. Now the script is launched, but it does not work as expected. It starts the script which outputs: User has asked for a return receipt. Send one? ([yes]/no): and waits for an input (read yn), but mutt adds its Press any key to continue So it seems that mutt already answers the question (what it shouldn't do). Also if I do press return to that question, it restarts the script and the game starts from the beginning. Endless, until i somehow force it to quit (not that easy). The (for now very basic script): #!/bin/sh TEMP=`mktemp` trap rm -f $TEMP INT ABRT EXIT tee $TEMP QUESTION=User has asked for a return receipt. Send one? ([yes]/no): echo -n $QUESTION read yn (I know that this is far from beeing complete, but to test how things would work it is enough) If you have used pipe-message I think your stdin has changed to the messages you piped. And read expects your answer from that filehandle. So you might try explicitly setting your tty with read yn /dev/tty This is how I do it for scoring people interactively. regards, Christian -- BLACK KNIGHT: Come on you pansy! [hah] [parry thrust] [ARTHUR chops the BLACK KNIGHT's right arm off] ARTHUR:Victory is mine! [kneeling] We thank thee Lord, that in thy merc- [Black Knight kicks Arthur in the head while he is praying] The Quest for the Holy Grail (Monty Python)
Re: Howto run a command in message hooks
On Wed, Oct 24, 2007 at 05:30:45PM +0200, Christian Brabandt wrote: If you have used pipe-message I think your stdin has changed to the messages you piped. And read expects your answer from that filehandle. So you might try explicitly setting your tty with read yn /dev/tty Okay, that might be an explanation why it does immedetiately print those mutt press any key message (btw. is it possible to suppress this message when calling the script?), but why does it recall and recall the script endlessly? Regards, Patrick
Re: Howto run a command in message hooks
On Wed, Oct 24, 2007 at 05:38:55PM +0200, Patrick Schoenfeld wrote: On Wed, Oct 24, 2007 at 05:30:45PM +0200, Christian Brabandt wrote: If you have used pipe-message I think your stdin has changed to the messages you piped. And read expects your answer from that filehandle. So you might try explicitly setting your tty with read yn /dev/tty Okay, that might be an explanation why it does immedetiately print those mutt press any key message (btw. is it possible to suppress this message when calling the script?), but why does it recall and recall the script endlessly? Just a guess, but maybe after running an external script, mutt re-runs the hooks; after all, it is still Before mutt displays (or formats for replying or forwarding) a message. The muttrc man page, at least, is not very specific (AFAICT) about when the hooks get run. In any case you'll presumably want some way of /not/ prompting the user to send the receipt if one has already been sent for this message; ideally some way that's built in to mutt, i.e. doesn't require an external script. -- Dave Evans http://djce.org.uk/ http://djce.org.uk/pgpkey signature.asc Description: Digital signature
Re: Howto run a command in message hooks
=- Patrick Schoenfeld wrote on Wed 24.Oct'07 at 17:18:54 +0200 -= and waits for an input (read yn), but mutt adds its Press any key to continue So it seems that mutt already answers the question (what it shouldn't do). Also if I do press return to that question, it restarts the script and the game starts from the beginning. Endless, until i somehow force it to quit (not that easy). As you've already learned, script doesn't wait for your input, it already got it from STDIN (EOT). What you see is only the prompt echo thrown into your regular mutt screen, while it actually already has returned to mutt. When you press enter again, why should it be any different from your first execution? Use q or x to see the difference. -- © Rado S. -- You must provide YOUR effort for your goal! EVERY effort counts: at least to show your attitude. You're responsible for ALL you do: you get what you give.
Re: Howto run a command in message hooks (was: Re: How to send a
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * Patrick Schoenfeld [EMAIL PROTECTED] [10-24-07 11:01]: On Wed, Oct 24, 2007 at 04:53:23PM +0200, Patrick Schoenfeld wrote: What information do you expect me to presentate? Eventually my whole mutt configuration just to ask why one specific message-hook (which I presentated) is not working? There is only one information that I see that I really missed to presentate: [EMAIL PROTECTED] ~ % mutt -v Mutt 1.5.16 (2007-06-11) ls -la ~/.mutt/return_receipt - -- Patrick Shanahan Plainfield, Indiana, USAHOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535@ http://counter.li.org -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.4-svn4472 (GNU/Linux) iD8DBQFHH4NEClSjbQz1U5oRAjceAJ4pOlmi7x1qRmA272w2bSVtP6XHwgCdHGKT 0PpyO/5MVyxTTnGMcFRy2No= =AO9N -END PGP SIGNATURE-
Re: Howto run a command in message hooks (was: Re: How to send a
On Wed, Oct 24, 2007 at 01:39:17PM -0400, Patrick Shanahan wrote: ls -la ~/.mutt/return_receipt You should work on you ability to _read_ mails others write _properly_. I told you, that the file _is_ executable. And as you eventually noticed someone else already pointed the right solution out to me, which were not a missing executable flag. -Patrick
Re: message-hooks - more examples
Rob -- ...and then Feztaa said... % % Alas! Sven Guckes spake thus: % Sven [mmh.. ye... deeper.. oh, yeah..] % % You sure that's a massage you're getting? ;) No, it's a m-e-ssage, but it's from one of those lists ;-) :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg26056/pgp0.pgp Description: PGP signature
Re: message-hooks - more examples
Alas! Sven Guckes spake thus: Sven [mmh.. ye... deeper.. oh, yeah..] You sure that's a massage you're getting? ;) -- Rob 'Feztaa' Park [EMAIL PROTECTED] -- Of course there's no reason for it, it's just our policy. msg26037/pgp0.pgp Description: PGP signature
Re: message-hooks - more examples
* Rob 'Feztaa' Park [EMAIL PROTECTED] [2002-03-25 05:33]: Alas! Sven Guckes spake thus: Sven [mmh.. ye... deeper.. oh, yeah..] You sure that's a massage you're getting? ;) I dunno... but I'm certainly HOOKED. hehe Sven
message-hooks
I'm trying to do something here, maybe it's not doable - who knows? what I want is that whenever I write or reply to a certain address, that message will be automagically BCCed to another address. I tried using send-hooks, but those do not seem to affect the current message, only subsequent messages. send-hook . 'unmy_hdr Bcc:' send-hook [EMAIL PROTECTED] 'my_hdr Bcc: [EMAIL PROTECTED]' (from memory) Is it possible? -- Dan Boger [EMAIL PROTECTED] msg23155/pgp0.pgp Description: PGP signature
Re: message-hooks
Date: Wed, 16 Jan 2002 08:36:55 -0500 From: Dan Boger [EMAIL PROTECTED] To: Mutt Users [EMAIL PROTECTED] Subject: message-hooks I'm trying to do something here, maybe it's not doable - who knows? what I want is that whenever I write or reply to a certain address, that message will be automagically BCCed to another address. I tried using send-hooks, but those do not seem to affect the current message, only subsequent messages. send-hook . 'unmy_hdr Bcc:' send-hook [EMAIL PROTECTED] 'my_hdr Bcc: [EMAIL PROTECTED]' Doesn't message-hook do what you describe here? -- FreeBSD 4.4-STABLE 7:21PM up 3 days, 23:18, 21 users, load averages: 0.03, 0.02, 0.00
Re: message-hooks
On Wed, Jan 16, 2002 at 07:21:28PM +0100, Roman Neuhauser wrote: what I want is that whenever I write or reply to a certain address, that message will be automagically BCCed to another address. I tried using send-hooks, but those do not seem to affect the current message, only subsequent messages. send-hook . 'unmy_hdr Bcc:' send-hook [EMAIL PROTECTED] 'my_hdr Bcc: [EMAIL PROTECTED]' Doesn't message-hook do what you describe here? nope, doesn't seem to do anything at all! -- Dan Boger [EMAIL PROTECTED] msg23168/pgp0.pgp Description: PGP signature
Re: message-hooks
On Wed, Jan 16, 2002 at 01:16:59PM -0500, Dan Boger wrote: On Wed, Jan 16, 2002 at 07:21:28PM +0100, Roman Neuhauser wrote: what I want is that whenever I write or reply to a certain address, that message will be automagically BCCed to another address. I tried using send-hooks, but those do not seem to affect the current message, only subsequent messages. send-hook . 'unmy_hdr Bcc:' send-hook [EMAIL PROTECTED] 'my_hdr Bcc: [EMAIL PROTECTED]' Doesn't message-hook do what you describe here? nope, doesn't seem to do anything at all! ok, I spoke prematurely... it does seem to work when I'm viewing a message that matches [EMAIL PROTECTED], but that's not quite the same... I want sending messages to [EMAIL PROTECTED], if it's a reply, or a forward, or a new message, I want it BCCed... -- Dan Boger [EMAIL PROTECTED] msg23170/pgp0.pgp Description: PGP signature