Mail queue and file locking

Discussion in 'Perl Misc' started by MadDogMcGee, Dec 3, 2004.

  1. MadDogMcGee

    MadDogMcGee Guest

    Hi there, here's what I'm trying to do:

    I'm on a Windows NT system, and want to monitor the Exchange mail queue for
    new files. When there's a new file (an email) with certain keywords (i.e.
    characteristic spam strings) I want to move the file to another folder so it
    doesn't get sent.

    Here's my approach, which is working but could probably be improved:

    1. Poll the folder (waiting 1 second between polls)
    2. If a file is "there", i.e. it has finished being copied across, and it is
    less than 1 megabyte, scan it for keywords.
    3. If the file has any keywords, move it to a different folder.
    4. Goto 1.

    To check if the file is copied across, I try to rename the file to itself.
    If it's locked, Perl's rename function returns a 0 and if it's unlocked,
    rename returns a 1.

    I'm worried that using this approach of renaming files will lock them, and
    prevent email from being moved out of the queue folder to be sent.

    1. Is there a better way to detect new files than to poll the directory
    every second?
    2. What's the best way to check if a file is unlocked (i.e. fully copied
    across)?
    3. (Off topic) Any potential problems in scanning the NT Exchange 5.5 mail
    queue folder and moving files out?


    Thanks!
     
    MadDogMcGee, Dec 3, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    8
    Views:
    526
    darrel
    Apr 5, 2006
  2. Russell Warren

    Is Queue.Queue.queue.clear() thread-safe?

    Russell Warren, Jun 22, 2006, in forum: Python
    Replies:
    4
    Views:
    685
    Russell Warren
    Jun 27, 2006
  3. Timasmith
    Replies:
    4
    Views:
    457
    Bjorn Borud
    Nov 1, 2006
  4. JaikeC
    Replies:
    1
    Views:
    2,359
    rowdyr86
    Feb 1, 2010
  5. Kris
    Replies:
    0
    Views:
    486
Loading...

Share This Page