in reply to problem in dumping sql results in a file
Another suggestion: don't use two scripts. Write one script that generates the attachment AND ALSO emails it. Even better, generate the attachment in memory, and don't even bother writing it to a file.