Could there be extra, non-visible characters attached to the subject coming
back?  You might want to try using a regular expression to do the
comparison.  It'll give you more control to pass or ignore stuff.

Something the following will ignore extra leading or trailing characters,
and ignore case changes from the original:

if ($_ =~ /$LOOKFOR/i ) {
  $FOUND = 1;
}

Hope this helps!

Samir


-----Original Message-----
From: Michael Weber [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, December 05, 2002 12:03 PM
To: [EMAIL PROTECTED]
Subject: Compare script fails

I am writing a script to check email functionality by sending a test
message to an account that forwards it back to a pop account.  I cannot
seem to get the script to match the expected subject lines with what was
received.  No matter what I do, it never shows a match.

Any ideas?

Here's the subroutine, output is below.

sub check_expected {
# This subroutine expects an array, @subjects, to contain zero or more
# subject lines from the messages retrieved from the bounced email pop
# account, and a file in /usr/local/netchecker/database/expected_mail
# that contains the unique subjects that were sent.
# The fourth piece of the subject is the account # that is being
tested.
# If the expected subject is not found in the returned emails, we save
# the failed account #s in /usr/local/netchecker/database/failed_mail
# which, when this script ends, is used by the calling shell script
# to run /usr/local/netchecker/<account#>/scripts/email_failure
scripts.

# Debug lines


        open (FAILURES, ">>
/usr/local/netchecker/database/failed_mail");
        open (EXPECTED,
"/usr/local/netchecker/database/expected_mail");
        print LOGFILE "check_expected  Entering while loop. \n";

        while ( <EXPECTED> ) {
                chomp;
                chomp;

print LOGFILE "Time is $hour:$min \n";
print LOGFILE "In while loop, expecting $_. \n";

                $FOUND = 0 ;
                chomp;
                $LOOKFOR = "$_";

                foreach (@subjects) {

print LOGFILE "Looking for $LOOKFOR in $_ \n";
print LOGFILE "Index is ", index( $_, $LOOKFOR ), "\n";

$NEWLOOKFOR = substr( $LOOKFOR, -8);
print LOGFILE "New Looking for $NEWLOOKFOR in $_ \n";


                        $FOUND = index( $_, $LOOKFOR );

# This didn't work either.
#                       if ( index( $_, $LOOKFOR ) >= 0 ) {
#                       $FOUND = 1;
#                       }

print LOGFILE "In foreach loop. Subject = $_  Found = $FOUND \n";

                }

        }

        close EXPECTED;
        close FAILURES;
        close LOGFILE;
}



Here's the log file output:

check_expected  Entering while loop.
Time is 19:55
In while loop, expecting 5_13_45_10001_7947 .
Looking for 5_13_45_10001_7947  in Subject: 5_13_45_10001_7947
Index is -1
New Looking for 01_7947  in Subject: 5_13_45_10001_7947
In foreach loop. Subject = Subject: 5_13_45_10001_7947  Found = -1


Thanx!

-Michael


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

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

Reply via email to