Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Not able to start a service in my computer

by kalyanbhave (Initiate)
on Sep 25, 2012 at 15:14 UTC ( #995566=perlquestion: print w/ replies, xml ) Need Help??
kalyanbhave has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am not able to start a service in my machine using the below code

#!/usr/bin/perl use strict; sub StartServ { $computername = ''; $servicename = 'ProtectedStorage'; Win32::Service::GetStatus("\\\\".$computername, $servicename, \%s +tatus); die "service is arealdy started\n" if ($status{CurrentState} == 4 +); Win32::Service::StartService("\\\\".$computername,$servicename) | +| die "Can't start service\n"; print "Service started\n"; }
Error:- Global symbol "$computername" requires explicit package name at xxx.pl line 6 Global symbol "$servicename" requires explicit package name at xxx.pl line 7. When I tried downloading the Service module which cantails packages, i am not able to execute it. please provide me the steps to execute and run the module.. Thanks

Comment on Not able to start a service in my computer
Download Code
Re: Not able to start a service in my computer
by nemesdani (Friar) on Sep 25, 2012 at 15:19 UTC
    If you use strict, variables have to be declared with my, e.g.

    my $computername = '';

    I'm too lazy to be proud of being impatient.
Re: Not able to start a service in my computer
by marto (Chancellor) on Sep 25, 2012 at 15:26 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://995566]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-09-21 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls