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

This is a bit off topic, but relevant for the work experience of many sysadms here, so I hope I don't irritate people. (I don't frequent anywhere else where there is a group of people with relevant Win experience.)

How do you do simple RPC interactions with Windows? I just need some small programs started (Perl, possibly VB) when a connection comes in.

This should be a Service -- it would be overkill to have a Perl server process listening for a few calls a day -- or installing Cygwin to get inetd and/or sshd.

This should be simple, but I can't find any open source sshd or similar. (E.g. 'freeSSHd' hasn't released code?) Searching for xml-rpc doesn't give much information on the Microsoft web page.

Replies are listed 'Best First'.
Re: Servers on Windows?
by Corion (Patriarch) on Nov 25, 2007 at 21:43 UTC

    If you have WMI/DCOM enabled on the Windows machines, you can launch arbitrary programs via WMI, if your account has the appropriate permissions. See the links in DBD::WMI resp. Win32::WQL.

      I wasn't clear -- I need to calls Window systems from non-Windows systems. (There are of course RPC systems between Windows computers.)

        If you're really desperate, I think the Samba project also includes a DCOM client, and I believe that DCOM and Sun RPC are somewhat related. But to use that as your transport you must be really desperate, as a simple self-made server is easily created depending on how secure you want it to be.

Re: Servers on Windows?
by ysth (Canon) on Nov 25, 2007 at 21:46 UTC
    I'm not clear on whether you are looking for server code (code that listens to a port and accepts connections) or code to install a windows service or both. For the former, perhaps search CPAN for RPC - lots of choices there. (Or just start from what's in perlipc.) For the latter, I see Win32::Daemon; there may be others, too.

    Search for openssh for an open source sshd, but I'm not sure what that has to do with the rest of your question.

      Sorry if I wasn't clear. I am asking for a light weight RPC implementation that I can call from non-Windows systems. Preferably, small and stable. I just need to (infrequently) start a small Perl sysadm program -- and get the result back.

      I have searched for open source sshd and didn't find anything except Cygwin, which isn't light weight.

      This is really trivial functionality. I don't understand why it seems so hard.

        I'm still not managing to see where sshd fits into your question - unless you envision taking its code and turning it into your rpc server, which seems like severe overkill.

        Yes, it is really trivial functionality. Start with Win32::Daemon; take the first part of the first example straight out of the pod:

        use Win32::Daemon; # Tell the OS to start processing the service... Win32::Daemon::StartService(); # Wait until the service manager is ready for us to continue... while( SERVICE_START_PENDING != Win32::Daemon::State() ) { sleep( 1 ); } # Now let the service manager know that we are running... Win32::Daemon::State( SERVICE_RUNNING );
        followed by the single-threaded server code straight out of the perl doc at, modified to just run your sysadm program and return its output in the body of the accept loop.


Re: Servers on Windows?
by cdarke (Prior) on Nov 26, 2007 at 08:57 UTC
    Are you sure you actually mean RPC and not IPC? Windows RPC (Remote Procedure Calls) uses its own implementation of DCE RPC which is generally not compatible with others. COM is implemented using Windows RPC, and so are a lot of Windows services (usually invisible to end-users). Although I have seen DCE RPC implemented on other systems, like Linux, personally I have never been able to get it working with Windows (that might have been me, of course).
    IPC (Inter-Process Communication) is much simpler, depending on what you want to do.

      I meant RPC, not Windows RPC. I have some servers where I need to start some simple sysadm scripts periodically and want to keep it as light as possible. Hence, no Cygwin, etc. (Without having to install a Visual C++ and compiling up a Service program.)

      Sigh, Thanks for info re DCE RPC implementations on Linux. :-(

        For periodically running stuff, I use Schedule::Cron::NoFork - but that requires a signed-on user or running as a service

Re: Servers on Windows?
by jbert (Priest) on Nov 26, 2007 at 12:10 UTC
    One option would be to tunnnel the request through an existing protocol the server is running. You could:
    • Invoke a CGI on a web server (just start job if it's long running)
    • create a flag file in a (hidden, locked down) directory on a file server, checked every N mins by a scheduled job on the server.
    Bit crufty, but should work easily (and both methods provide good auth support, which you'll presumably want).
Re: Servers on Windows?
by BerntB (Deacon) on Nov 26, 2007 at 14:00 UTC

    In the end I went with WinSSHD (over FreeSSHd). If it works the coming weeks, we'll use that. Otherwise, I guess it'll be a Perl program.

    Thanks for the help, insight and input!