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
Replies are listed 'Best First'.
Re: Not able to start a service in my computer
by marto (Bishop) on Sep 25, 2012 at 15:26 UTC
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.

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 about the Monastery: (10)
As of 2015-07-07 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls