Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Fire a script on Windows from Linux

by TechFly (Scribe)
on Jun 26, 2014 at 14:52 UTC ( #1091363=perlquestion: print w/replies, xml ) Need Help??
TechFly has asked for the wisdom of the Perl Monks concerning the following question:

I have a process that I am working on that requires me to run some script on my linux hosts, and have that script start a batch script on a windows host. I have been having trouble finding a good way to do this. I could install SSH on windows, but most of the non-commercial packages are many years out of date. I have not found anything on cpan that quite does what I need. On the windows box, there is a batch script that I need to start. It does some logging, and then starts a service. I am unsure as to how to proceed. Has anyone done this before?

For extra background, the windows host is a windows 2008 R2 server that runs a critical app in my environment. The 'powers that be' would prefer I not install, or mess with the windows box any more than required. Cygwin is out of the question in this case for political reasons.

Replies are listed 'Best First'.
Re: Fire a script on Windows from Linux
by Limbic~Region (Chancellor) on Jun 26, 2014 at 15:11 UTC
    Let me give you a somewhat unconventional answer - use a web page. You can use IIS and whatever CGI available on the box (Actionscript, Asp, PHP, Perl, etc). Create a simple web form that when submitted tells the windows box what to do. The form can then render a page with the results that the remote process can parse for feedback.

    This may seem like a lot more work than is necessary and depending on your "powers that be" may not be acceptable. On the other hand, by divorcing the direct interaction you create the ability to be implementation agnostic.

    This same concept could be done in a myriad of ways. For instance, if both hosts shared a file system (Samba, NFS, etc) then you could communicate by placing files in the directory and having processes on each end monitor for.

    Cheers - L~R

Re: Fire a script on Windows from Linux
by dasgar (Priest) on Jun 26, 2014 at 18:22 UTC

    The first thing that comes to mind is to do something like what Limbic~Region suggested - which is to have Perl scripts running on the two systems that communicate with each other somehow (web interface, files on shared storage, etc.).

    Here's a general idea of what I used between two Windows systems, but should work for you. On one system, I used IO::Socket::INET::Daemon to create a "telnet" server that would run do something with local hardware and return information to the client. I used Task Scheduler to start the script on system start even if no user is logged on. Then I used Net::Telnet from another system to interact with the "telnet" server.

    Regardless of the route that you choose to go, the basic idea is that you have to have some kind of service (such as web/telnet/ssh server or script/executable running) on the Windows system, which means that you will have to make some kind of change to the Windows system so that something is running so that your remote system can interact with it.

Re: Fire a script on Windows from Linux
by syphilis (Chancellor) on Jun 27, 2014 at 00:18 UTC
    Has anyone done this before?

    I'm sure it has been done by lots of people.
    I used to do it via TCP socket connections - a server (perl) script on the Windows machine listens on a particular port for the message/ping from the Linux machine.
    Upon receipt of the message/ping, the server script then sets in motion the desired process and resumes listening (or whatever).

    Chapter 17 of the "Perl Cookbook" is one resource for how to set this up, giving examples of both the "server" side and "client" side code requirements. There are, no doubt, other resources.

Re: Fire a script on Windows from Linux
by 1s44c (Scribe) on Jun 27, 2014 at 08:14 UTC

    I've done this.

    I tried out every RSHD for windows I could get my hands on and the only one that worked for me was Denicomp RSHD. I'd much prefer open source but none of it 'just worked' like the denicomp version. It's only 45 USD per machine. See

    RSHD uses IP based authentication so your security people might disallow this.

    The other approach I considered was a timed script on the windows machine that checks for input in some shared directory and does its thing if it finds any. Run it every 5 minutes or so.

    Whatever approach you take make sure you have monitoring to check it keeps working.

Re: Fire a script on Windows from Linux
by codiac (Beadle) on Jun 27, 2014 at 10:15 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1091363]
Approved by marto
Front-paged by toolic
and a soft breeze sighs...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-01-23 02:02 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (238 votes). Check out past polls.