zsh-users
 help / color / mirror / code / Atom feed
From: DervishD <disposable1@telefonica.net>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Mail spooler with zsh
Date: Tue, 31 Aug 2004 13:31:51 +0200	[thread overview]
Message-ID: <20040831113151.GA5097@DervishD> (raw)

    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/


             reply	other threads:[~2004-08-31 11:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-31 11:31 DervishD [this message]
2004-09-01  9:20 ` Bart Schaefer
2004-09-01 11:45   ` DervishD

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=20040831113151.GA5097@DervishD \
    --to=disposable1@telefonica.net \
    --cc=zsh-users@sunsite.dk \
    /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).