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
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