mdog has asked for the wisdom of the Perl Monks concerning the following question:
use CGI qw/:standard escape unescape/; use Win32; use Win32::Service; my $Server = ""; my %statusCode; $statusCode{1} = "Stopped"; $statusCode{4} = "Started"; my $serviceName = $ARGV[0]; my $action = $ARGV[1]; main(); sub main{ print header; print "hi"; stopService($Server,"MSFtpsvc"); #if($action eq "start"){ # startService($Server,$serviceName); #} elsif($action eq "stop"){ # stopService($Server,$serviceName); #} #ServiceState(); } sub ServiceState{ my %status; Win32::Service::GetStatus($Server, $serviceName, \%status); print qq|Service $serviceName is currently: | . $statusCode{$statu +s{CurrentState}} . "\n"; } #********************************************************************* # Stop/Start service sub stopService { my ($Server, $Service) = @_ ; my %status; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} eq "4"){ Win32::Service::StopService($Server, $Service); } sleep 5; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} ne "4"){ print "$Service is stopped\n"; } } sub startService { my ($Server, $Service) = @_ ; my %status; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} ne "4"){ Win32::Service::StartService($Server, $Service); } sleep 5; Win32::Service::GetStatus($Server, $Service, \%status); if($status{CurrentState} eq "4"){ print "$Service is started\n" } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI + IIS + Win32::Service == Doh!
by NetWallah (Canon) on Feb 14, 2004 at 21:59 UTC | |
by paulbort (Hermit) on Feb 15, 2004 at 20:35 UTC | |
by mdog (Pilgrim) on Feb 15, 2004 at 18:49 UTC | |
by NetWallah (Canon) on Feb 16, 2004 at 01:09 UTC |