From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4385 invoked from network); 31 Aug 2004 11:34:01 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Aug 2004 11:34:01 -0000 Received: (qmail 28740 invoked from network); 31 Aug 2004 11:33:54 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Aug 2004 11:33:54 -0000 Received: (qmail 23685 invoked by alias); 31 Aug 2004 11:33:04 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7952 Received: (qmail 23674 invoked from network); 31 Aug 2004 11:33:03 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 31 Aug 2004 11:33:03 -0000 Received: (qmail 27012 invoked from network); 31 Aug 2004 11:31:10 -0000 Received: from madrid10.amenworld.com (62.193.203.32) by a.mx.sunsite.dk with SMTP; 31 Aug 2004 11:31:08 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id i7VBV6107796 for ; Tue, 31 Aug 2004 13:31:07 +0200 Received: from disposable1@telefonica.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1C26rf-00022U-00>; Tue, 31 Aug 2004 13:31:51 +0200 Date: Tue, 31 Aug 2004 13:31:51 +0200 From: DervishD To: Zsh Users Subject: Mail spooler with zsh Message-ID: <20040831113151.GA5097@DervishD> Mail-Followup-To: Zsh Users Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4.2.1i Organization: Pleyades X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 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/