Forum Moderators: coopster & phranque

Message Too Old, No Replies

mail alert

         

perl12

8:44 am on Feb 12, 2004 (gmt 0)

10+ Year Member



Hi,
I am trying to send a mail alert to a person x when ever the status is anything else but "Okay" after running the metastat command....The output of the metastat comment is something like this
"d15: Submirror of d17
State: Okay
Size: 35205120 blocks
Stripe 0:
Device Start Block Dbase State Hot Spare
c2t5d4s2 0 No Okay"

I have written a script here but I am not sure what condition I have to give in the if sentence. Pls help me with this.
My script is something like this:
#! /usr/atria/bin/Perl

if (-f "/usr/ucb/mail") {
$mail = "/usr/ucb/mail";
} else {
$mail = "/usr/bin/mail";
}

$curu = $ENV{"CLEARCASE_USER"};

print ("Enter a number: ");
chop ($num = <STDIN>);
print ("Guess a number: ");
chop ($guess = <STDIN>);
if ($num eq $guess) {
print "Sending mail to shegde\n";
$cmd = "$mail -s 'ClearCase Notify' shegde";
open(TOMAIL,"¦ $cmd" ) ¦¦die("Can't mail\n");
print TOMAIL "User: $curu\n";
print TOMAIL "\n\n";
print TOMAIL "Error.\n";
close(TOMAIL);
}

cheers,
perl12

greggb

12:36 am on Feb 13, 2004 (gmt 0)

10+ Year Member



Hi. I'm going to venture a guess here, though I'm not really sure this will answer your question or help you any.

I guess I'm not exactly sure what you're trying to do in your conditional statement. But if you're attempting to check to see if one path to your mailer program exists and:
1) use it if it exists
2) use another path if it doesn't exist

(If the above are true)
I would use the -e instead of -f. -e is used to see if a file exists. -f is used to determine if a file is a regular file--I'm not really sure what that means because I've never used it, but I've always used -e, and it's always worked well for me.

Hope that helps, sorry if it doesn't.
Gregg