Re: Daemonizing CRM114 using FIFO

Paolo <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <20080923070549.GA14158@localhost>
On Mon, Sep 22, 2008 at 11:22:39PM +0200, Ger Hobbelt wrote:

ok, that's the not too short answer :) 

> (a) is 'delineating' a message - the 'end of message' marker. Two

let's stress that this can be done at script level, using all the tricks
and tools in your *ix box. Eg I used a couple of md5sum as markers - that's
string matching, easy with crm114.
The hard thing is dealing with buffered I/O: there's no good way around it 
except do proper timing, which makes your daemonizing effort nonsense.
So you need to feed the stream with start/end markers and crm needs to loop
on INPUT and rely on such markers, not on EOF.

> (b) Which leaves the second issue, which you already ran into and
> resolved by open+close on the one side plus wait on the other: this is

yep, and see above - you gain nothing except an headache, unless you've got
a *very* complex .crm script; if your script is like sample you post, you
are better off doing the usual 1 crm invocation per msg.

ATM INPUT doesn't provide the proper IOCTL flags to deal properly with pipe
like PERL does; if you feel like hacking the INPUT statement, check what 
others have done, like on-screen daemon (onscreend, sorry don't have URL
handy) and CLAMAV (both the FIFO and protocol stuff).

For both async/sync cases, try to hack to your taste the following sample:

!window
!{
!  isolate (:content:) //
!  isolate (:z:) //
!  isolate (:x:) /0/
!  :loop:
!  { input [/tmp/dynamic_fifo]
!    { match (:: :z:) /(.*)\n=>FINE<=\n/
!      eval (:x:) /:#:_dw:/
!      #output /:_dw: :*:x: /
!      alter (:content:) /:*:content::*:z:/
!      goto /:do_it:/
!    }
!    alter (:content:) /:*:content::*:_dw:/
!    liaf
!  }
!  goto /:loop:/
!  :do_it:
!  eval (:x:) /:#:content:/    
!  classify <osb unique microgroom> \
!       (A.css B.css C.css D.css) (:_dw:) [:content:]
!  output /:*:x:\n/
!  #output /:*:_dw:\n\n/
!  alter (:content:) //
!  alter (:z:) //
!  alter (:_dw:) //
!  goto /:loop:/
!  exit
!}
!

which you'd start like

! crm -e /tmp/dynamic.crm &

then you'd feed the FIFO like

! for f in $list;do
!   { cat "$f"; printf "\n=>FINE<=\n"; } > /tmp/dynamic_fifo
! done

HTH
-- 
paolo

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.