m my name is.. my name is.. emanon: check ....am i online

Wednesday, May 31, 2006

check ....am i online

#!/usr/bin/perl
#Checks if entowts is online. If not, start it up

use strict;
use Date::Manip;
use Sys::Hostname;

my $pattern = "entowts.sh";
my $ctr = 0;

open FH, "/bin/ps -eaf /bin/grep \"$pattern\" grep -v \"grep\"";
while () {
if (m/$pattern/) {
$ctr++;
}
}
close FH;

if ($ctr != 1) {
# There should always be one entowt
# If it's you are not entowt then logoff now
my $mail = "/usr/bin/mailx";
my $recipient = 'entowts@yahoo.com';
my $hostname = hostname();
open MAIL, "$mail -s \"entowts online: $hostname\" $recipient"; print MAIL "This is automatically generated by entowts script.";
print MAIL "=========\n\n";
print MAIL "INFO: Running d:/ekstrim/ekstrim.sh start\n";
system "d:/entowts/entowts.sh start";
print MAIL "Online process:\n";
open FH, "/bin/ps -eaf /bin/grep \"$pattern\" grep -v \"grep\"";

while () {
if (m/$pattern/) {
print MAIL $_;
}
} close FH;
close MAIL;
}

0 Comments:

Post a Comment

<< Home