
saravanansrivai
Deleted
Aug 1, 2000, 12:54 PM
Post #4 of 5
(13216 views)
|
Re: Using Win32::service module
[In reply to]
|
Can't Post
|
|
These are routines i have used on my script for starting & stopping & Getting the status of "mysql" service.U can customize it for any service. Win32::Service; #### Check mysql service status,return true if the servcie is running sub mysqlStatus { ## Check Win32 Services #Win32::Service::GetServices("",\%srvs); Win32::Service::GetStatus("",$srv,\%status); #print ("Service= $srv\n\n"); #foreach $key2 (sort keys %status) {print ("Status=$key2===>$status{$key2}\n");} if ($status{'CurrentState'}==4){print "Mysql service is Running!!!\n";return 1;} else {print "Mysql service is not Running!!!\n";return 0;} } #### Stop mysql service status,return true if the servcie is Stopped sub mysqlStop { print "Stopping Mysql service !!!\n"; print ACTLOG ("Stopping Mysql service !!!\n"); Win32::Service::StopService("","$srv"); Win32::Service::GetStatus("","$srv",\%status); if ($my_srv{CurrentState}==1) { return 1; } else { return 0;} } #### Start mysql service status,return true if the servcie is Started sub mysqlStart { print "Starting Mysql service !!!\n"; print ACTLOG ("Starting Mysql service !!!\n"); Win32::Service::StartService("","$srv"); Win32::Service::GetStatus("","$srv",\%status); if ($my_srv{CurrentState}==4) { return 1; } else { return 0;} }
|