Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Help needed with WIN32::Service

by the_hawk_1 (Scribe)
on Jun 28, 2010 at 17:06 UTC ( [id://846946]=perlquestion: print w/replies, xml ) Need Help??

the_hawk_1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow monks,

I've got a trouble with getting status, stopping and starting service on a remote server.

Right now, I can't event get the status!

Here is the code :

#!/usr/local/bin/perl use strict; use warnings; $|=0; use Win32::Service; my %status; Win32::Service::GetStatus("VL94196",'SendLogServer', \%status); print "SendLogServer : ".$status{'CurrentState'}."\n";
Where the VL04196 is the machine name and SendLogServer is the service. Here is what I've got has answer:
Use of uninitialized value in concatenation (.) or string at Z:\Script +Perl\TMP\services.pl line 21.

Can you enlight me?

Replies are listed 'Best First'.
Re: Help needed with WIN32::Service
by BrowserUk (Patriarch) on Jun 28, 2010 at 17:52 UTC
    Z:\ScriptPerl\TMP\services.pl

    Is that the path & name of the code you posted?

      Sorry, I forgot to mentionned!

      Yes it is.

        Hm. An error on line 21 of an 11 line script is interesting. It's quite hard to see how that could come about.

        Could you install Devel::Trace and then run your script using it and post the output here. It should only be a few lines.

        perl -d:Trace Z:\ScriptPerl\TMP\services.pl

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Help needed with WIN32::Service
by NetWallah (Canon) on Jun 28, 2010 at 18:58 UTC
    You need to prepend "\\" to the server name. (Update) I have seen evidence to the contrary.

    Perl strings require that the backslashes be doubled.
    Try:

    Win32::Service::GetStatus("\\\\VL94196",'SendLogServer', \%status) or + die "Service status failed: $!"
    Most likely, 'SendLogServer' is not the short-name for the service you seek.

    The second parameter is the short name. You need to error-check the return, otherwise,$status{'CurrentState'} will be undef, and you will get the "uninitialized" warning.

         Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

      Thanks NetWallah, but I forgot to mention that when I try this directly on the machine, it works well, but I can't do it remotly.

      So, I'm sure about the service name.

      I've also tried with the '\\\\' or the ip address, but both didn't work neither.

        Is there any indication in the "die" error message as to what the problem is ?

        How about the event logs, particularly the security logs ? There could be firewall or authentication issues.

             Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found