zsh-users
 help / color / mirror / code / Atom feed
* Mail spooler with zsh
@ 2004-08-31 11:31 DervishD
  2004-09-01  9:20 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: DervishD @ 2004-08-31 11:31 UTC (permalink / raw)
  To: Zsh Users

    Hi all :)

    I'm writing a simple mail spooler to queue mail before sending
with msmtp. This MTA doesn't do queuing and I thought that it would
be a good idea to write the queuing part as a zsh script.

    More or less the script has the following structure:

    - Queue the new mail message
    - Try to send each queued mail
    - Remove from the queue any successfully sent message.

    The first part I'm implementing using the maildir algorithm, to
allow multiple instances of the queuer running in the same spool
directory, and here come the problems.

    The maildir algorightm needs some stat calls (this can be solved
using the zsh/stat module or simple '[[]]' tests) and a timeout test.
The timeout is to avoid block for a very long time in case the system
clock is set backwards. Well, I think that the timeout can be
implemented using $TMOUT, but in a script (non interactive of course)
there is no prompt and TMOUT doesn't seem (obviously) to work :(

    It has occurred to me that I can set up a counter and instead of
checking for time passed I check for number of failed 'stat' calls.
But for this to be successful even in the case of the clock been set
backward a lot of time, I need to use a finer-grain control:
nanoseconds. How in zsh can I obtain the nanoseconds as in 'date
+%N'? I want to avoid calling 'date' in every loop since 'print -P
%D{}' is a bit faster (in fact it is more than 10 times faster...).

    I could use 'safecat', I know, but I prefer to do all the script
using just builtin commands. Moreover, safecat has 24hour timer and
only seconds of resolution, and although I never set my clock back in
time, you never know... ;)

    Thanks in advance :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Mail spooler with zsh
  2004-08-31 11:31 Mail spooler with zsh DervishD
@ 2004-09-01  9:20 ` Bart Schaefer
  2004-09-01 11:45   ` DervishD
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2004-09-01  9:20 UTC (permalink / raw)
  To: Zsh Users

On Tue, 31 Aug 2004, DervishD wrote:

>     The maildir algorightm needs some stat calls (this can be solved
> using the zsh/stat module or simple '[[]]' tests) and a timeout test.
[...]
> there is no prompt and TMOUT doesn't seem (obviously) to work :(

Use the zselect command.  Requires loading the zsh/zselect module.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Mail spooler with zsh
  2004-09-01  9:20 ` Bart Schaefer
@ 2004-09-01 11:45   ` DervishD
  0 siblings, 0 replies; 3+ messages in thread
From: DervishD @ 2004-09-01 11:45 UTC (permalink / raw)
  To: zsh-users

    Hi Bart :)

 * Bart Schaefer <schaefer@brasslantern.com> dixit:
> >     The maildir algorightm needs some stat calls (this can be solved
> > using the zsh/stat module or simple '[[]]' tests) and a timeout test.
> [...]
> > there is no prompt and TMOUT doesn't seem (obviously) to work :(
> Use the zselect command.  Requires loading the zsh/zselect module.

    I was trying to avoid that because that requires to upgrade Zsh
and I don't want to do it by now :( Thanks anyway, Bart :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-09-01 12:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-31 11:31 Mail spooler with zsh DervishD
2004-09-01  9:20 ` Bart Schaefer
2004-09-01 11:45   ` DervishD

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).