Script seems to work well.  I can send it blank fields and it recovers
every time.  Problem is when I leave it running it crashes with the now
infamous Can't use an undefined value as a hash reference At line 16.  When
it does this there is nothing in the inbox to process.  I added 'or ()' to
get around this problem, which seems to work when I send it blank fields.
What else can I do to avoid this problem?

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

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) {
    my $t = (localtime);
    print "$t\n";
    sleep 1;
    my $AllDocuments = $Database->AllDocuments or next;
    my $Document = $AllDocuments->GetFirstDocument or next;
    my $From = $Document->GetFirstItem('From')->{Text} or ();     #  This
is the line it's crashing on
    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 next;
        my $delete = $AllDoc->GetFirstDocument or next;
        $delete->Remove(1) or next;

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

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]

Reply via email to