Below is a perl script I've been working on that logs into and checks a notes email account for new messages once every second. When it finds a new message it tests for a password, and if it success it process's the email. The script will based on what is in the email either run another script, or do anything that can be done form a command line on the system it is running on. It then clears the mailbox, then goes back into the loop where it checks for any mail. The original propose for this program was to allow me to do some diagnostics remotely via email (usually my blackberry handheld), but I've already found dozens of other uses for it.
The problem is that the script is supposed to loop basically forever until it finds something. It does this for awhile. The program works for about 24 hours at which point it just stops. I've tried changing to loop time from 1 second to 10, and even 30 seconds, but it still crashes after about 24 hours. I've never managed to be around when this happens to try to figure out what is going on. Looking for improving programs stability, or even ideas on how to get it to log what is going wrong. Only thing I can think of is having it open a text file, and have every line in the program log it's execution in some way. I've also already added lines that force it back into the waiting loop at almost every stage I can think of it possibly halting, but that has had little of any effect it seems. If anyone has any ideas on how to improve this programs stability, how to make perl programs more stably in general, or even a possible reason why this, or any general purpose program might crash for unknown reasons let me know. Looking for input of any kind on this issue. Have been thinking of writing some simple but very system specific network monitoring apps using perl and I really need to prove to myself that I can keep a perl script running for weeks at a time before I even start. #################################################################################################### use strict; use warnings; use diagnostics; use Win32::OLE; #Notes database Info my $userid = "xxxxxx"; my $server = "xxxxx/xxx/xxx"; #Log into Notes database my $Notes = Win32::OLE->new('Notes.NotesSession'); my $Database = $Notes->GetDatabase("$server", "mail\\$userid.nsf"); #Loop a check for mail once every second, send a '.' to console for monitoring WAIT: sleep 1; print "."; my $AllDocuments = $Database->AllDocuments; my $Document = $AllDocuments->GetFirstDocument or goto WAIT; #Process mail my $From = $Document->GetFirstItem('From')->{Text} or goto WAIT; my $Password = $Document->GetFirstItem('Subject')->{Text}; my $Command = $Document->GetFirstItem('Body')->{Text}; my $Subject = "CMD: $Command"; #Password Check - Password must be in subject line of email unless ($Password eq "xyz") {goto BADPASS} #execute command my $Report = `$Command`; print "!"; #Send reply mail SENDMAIL: my $ReportMail = $Database->CreateDocument('NEW') or goto WAIT; $ReportMail->{Form} = 'Memo'; $ReportMail->{Body} = "$Report"; $ReportMail->{SendTo} = "$From"; $ReportMail->{Subject} = "$Subject"; $ReportMail->Save(1, 1); $ReportMail->Send(0); #Clear the mailbox foreach (1..3) { my $AllDoc = $Database->AllDocuments or goto WAIT; my $delete = $AllDoc->GetFirstDocument or goto WAIT; $delete->Remove(1) or goto WAIT; } goto WAIT; #Password Fails - Reformat reply mail and log the attack BADPASS: $Report ="You do not have access to this system. This attack has been logged"; $Subject = "ACCESS DENIED"; open(BAD, ">>BADPASS.TXT") or goto WAIT; print BAD "\n\nACCESS VIOLATION: \nFrom: $From\nSubject: $Password\nBody:\n\n$Command \n\n " or goto WAIT; close(BAD); print "#" or goto WAIT; goto SENDMAIL; goto WAIT; ######################################################################################### Chris Benco Network Administrator Austin Powder Company 216-464-2400 x277 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]