call win32 API from linux perl script

B

broutard

Hi,

I'm must calling an API from a remote win32 server in a perl script.
On a windows server, I use win32::OLE and it's work fine !

But my perl script must run on a linux server and must call this win32 API !
Apparently, it's impossible to install win32::OLE on linux.

So, how can i do ??


Thanks
 
B

Ben Morrow

Quoth (e-mail address removed) (broutard):
I'm must calling an API from a remote win32 server in a perl script.
On a windows server, I use win32::OLE and it's work fine !

But my perl script must run on a linux server and must call this win32 API !
Apparently, it's impossible to install win32::OLE on linux.

So, how can i do ??

AFAIK COM+ automation (OLE) doesn't allow you to interact with an object
on another machine, so you would have the same problem calling an OLE
function on one windows machine from another. What you need to do is set
up a perl script that is always running on the Win32 machine, waiting
for connections; then, when it receives one, it makes the OLE call and
passes the results back to the other end.

This sort of setup is called 'RPC' for 'Remote Procedure Call' and there
are modules on CPAN which will handle both ends for you, for a variety
of standard protocols. Try starting with RPC::Simple or XMLRPC::Lite.
If none of these will fit your needs, for whatever reason, you will need
to design your own protocol and implement a server for the Win32 box and
a client for the linux box. Getting this sort of design right is not the
easiest thing in the world, though, so you would be better off using one
of the standard modules if you can.

Ben
 
P

Petri

AFAIK COM+ automation (OLE) doesn't allow you to interact with
an object on another machine, so you would have the same problem
calling an OLE function on one windows machine from another.

This is exactly what COM+ is meant for, distributing backend logic onto other
machines.
It is way of accomplishing middle-tier resource sharing, to protect more
expensive resources such as database connections.
It used to be called MS Transaction Server in the NT4 days.
You can also run separate DCOM (Distributed COM) components, outside of the COM+
resource sharing environment.

When you are running remotely, you have to remember to provide a matching
identity and correct authentication.


Petri
 
C

Chris

l said:
I once did something similar to this however I used http as the listener
to run the windows perl script. I needed to connect to an ODBC
connection behind a firewall, port 80 was the only port open. The unix
server used LWP to *run* the win perl script via http. The sql was
passed in the url and the results were passed back as pairs of
"key=value\n" which was quickly stored into a hash. I still had to
design my own protocol but that was what made the task fun to work on.

Could have saved yourself some time and work (and had just as much fun)
using XML-RPC. The protocol is already defined and uses port 80 (HTTP),
which is what it was designed for. This, as Ben Morrow has already
suggested, could be one approach to the OP's problem and one I would
recommend as well (eg. some RPC approach).

-ceo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top