[imapfilter-devel] daemon mode
Phil Osipher
phlosipher at yahoo.com
Tue Nov 2 06:52:48 EET 2010
Please forgive the following very stupid question.
In learning imapfilte rand lua I have written some reasonably complex imapfilter and lua scripts, and although I am new to them, they seem to work fine when executed "once".
But I am puzzled over the use of the "daemon mode".
Here is the issue. My employer does not allow me to store password in scripts, or files accessed by scripts. (Encrypted or not). So to filter a mailbox, I have decided to start an imapfilter script interactively in the console, query for a password, and then switch to daemon mode to occasionally access a mailbox folder for days or weeks continuously and do some stuff to it (which I may post later to ask for advice/improvements about at a later date).
But I am not having any luck with using the tools in daemon mode.
Here is a simple example of a script, simplified to get to the essence of the problem and make it easy for you to help me
--------------------------------
function forever()
account1 = IMAP {
server = 'server.domain.com',
username = 'user at domain.com',
password = passwd,
}
print("b")
end
passwd = "abcd"
print("a")
--daemon_mode(10,forever)
become_daemon(10,forever)
--forever()
print("c")
--------------------------
The script behaves predictably if I enable the line that invokes function "forever" explicitly.
e.g. invokng the script with "imapfilter -c test.lua" when I enalbe the line "forever()" produces output
a
b
c
But if I modify the script to use the line with "daemon_mode" or "become_deamon" it prints
"a", then hangs. I expected it to repeat "b" repeatedly every 10 seconds, and never reach the line to print "c".
What am I doing wrong? It must be something very simple. So sorry to be missing something basic. I have tried "flushing" stdout (not shown) but that doesn't seem to help. I must be missing something else that is simple.
Also, what is the difference between "become_daemon" and "daemon_mode"?
Thanks for the help
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hellug.gr/pipermail/imapfilter-devel/attachments/20101101/da980666/attachment.html>
More information about the Imapfilter-devel
mailing list