in reply to Strange problem trying to clean garbage from start of mailbox file

This doesn't explain the problem you're having, but have you considered the possibility that the 'garbage' at the start of your mailbox files might span multiple lines? Your code doesn't account for that possibility.

More to the point, you don't check for failure on open, yet later you use system to overwrite the file. While it doesn't seem likely that you would be able to overwrite a file that you couldn't open, it makes me nervous to see you opening a file without checking the result of that open.

  • Comment on Re: Strange problem trying to clean garbage from start of mailbox file

Replies are listed 'Best First'.
Re^2: Strange problem trying to clean garbage from start of mailbox file
by capoeiraolly (Initiate) on Feb 02, 2006 at 22:37 UTC
    Ok the problem is that the script seems to randomly empty the mailbox files (on the BSD box) instead of just removing single/multiple lines of garbage. Sometimes it will work on a mailbox, sometimes it won't... I haven't seen any pattern to it yet.

    Haven't bothererd with the file opening checking yet because I'm still just testing. It's a contained environment that I'm testing this in, not the actual mailboxes.

    The code should account for multiple lines of garbage, the while loop will read in a line at a time of the file until the file is either empty or untill the index of "From" is 0.

    The test I'm running on BSD (errors) is exactly the same as the one that works running on my Debian (no errors) machine. I'm only running it on about 10 mailboxes, with a mixture of corrupted and non corrupted files.