Having problems when this script hits a hash that is undefined.  This
happens when it does a look-up for a field in a notes database and it is
blank.  Read on Perl Monks to give it the ability to use another value when
this happens to keep the script form halting.  The example they give was
something like this.

my $From = $Document->GetFirstItem('From')->{Text} or ();

This appears to work.  When I run a test the program recovers seemingly
flawlessly.  My problem is that the script still dies at some point.  When
I come in the next day it shows a hash reference on an undefined value
error in line 15.  This is the 'From' line, and when I send an email to it
with a blank from line it recovers and works fine.  There is no mail in the
system at all during the time of the crash. Going to add a time log to the
loop in the script so I can better tell exactly when it is dying.  If
anyone has any suggestions they are all welcome.  Below is the complete
current revision on the script.


###########################################

use strict;
use diagnostics;
use Win32::OLE;

my $userid = "xxx";
my $server = "xxx/xxx/xxx";
my $Notes = Win32::OLE->new('Notes.NotesSession');
my $Database = $Notes->GetDatabase("$server", "mail\\$userid.nsf");

while (1) {
    sleep 1;
    print ".";
    my $AllDocuments = $Database->AllDocuments or next;
    my $Document = $AllDocuments->GetFirstDocument or next;
    my $From = $Document->GetFirstItem('From')->{Text} or ();
    my $Password = $Document->GetFirstItem('Subject')->{Text} or ();
    my $Command = $Document->GetFirstItem('Body')->{Text} or ();
    my $Subject = "CMD: $Command";
    if ($Password eq "xyz") {
        $a = `$Command`;
        print "!";
    } else {
        $a ="You do not have access to this system.  This attack has been
logged";
        $Subject = "ACCESS DENIED";
        open(BAD, ">>BADPASS.TXT");
        print BAD "::ACCESS VIOLATION:: \nFrom: $From\nSubject:
$Password\nBody:\n\n$Command \n\n ";
        close(BAD);
        print "#";
    }
    my $Report = "$a";
    my $ReportMail = $Database->CreateDocument('NEW');
    $ReportMail->{Form} = 'Memo';
    $ReportMail->{Body} = "$Report";
    $ReportMail->{SendTo} = "$From";
    $ReportMail->{Subject} = "$Subject";
    $ReportMail->Save(1, 1);
    $ReportMail->Send(0);
    foreach (1..3) {
        my $AllDoc = $Database->AllDocuments or return;
        my $delete = $AllDoc->GetFirstDocument or return;
        $delete->Remove(1) or return;
    }
}

#############################################

Chris Benco
[EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to