<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Please forgive the following very stupid question.<br><br>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". <br><br>But I am puzzled over the use of the "daemon mode". <br><br>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). <br><br>But I am not having any luck with using the tools in daemon mode.<br><br>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 <br><br>--------------------------------<br>function forever()<br>account1 = IMAP {<br> server = 'server.domain.com',<br> username = 'user@domain.com',<br> password = passwd,<br>}<br>print("b")<br>end<br><br>passwd = "abcd"<br><br>print("a")<br><br><br>--daemon_mode(10,forever)<br>become_daemon(10,forever)<br>--forever()<br>print("c")<br>--------------------------<br><br>The script behaves predictably if I enable the line that invokes function "forever" explicitly.<br>e.g. invokng the script with "imapfilter -c test.lua" when I enalbe the line "forever()" produces output<br><br>a<br>b<br>c<br><br><br>But if I modify the script to use the line with "daemon_mode" or "become_deamon" it prints <br>"a", then hangs. I expected it to repeat "b" repeatedly every 10 seconds, and never reach the line to print
"c".<br><br>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.<br><br>Also, what is the difference between "become_daemon" and "daemon_mode"?<br><br><br>Thanks for the help<br><br>Phil<br><br><br><br></td></tr></table><br>