Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Win32::OLE, TPJ#10, linux

by Anonymous Monk
on Sep 06, 2004 at 10:56 UTC ( [id://388771]=perlquestion: print w/replies, xml ) Need Help??

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

In Jan Dubois' article in TPJ#10 about Win32::OLE, Jan mentions
"out-of-process servers... they are standalone executables that exist as separate processess -- possible on a different computer."
Is there a way to run Win32::OLE on a linux machine to drive Office apps on a WinXP box?

Win32::OLE wouldn't install for me under linux using the cpan installer.

Thank you very much.

Replies are listed 'Best First'.
Re: Win32::OLE, TPJ#10, linux
by Corion (Patriarch) on Sep 06, 2004 at 11:09 UTC

    Win32::OLE only works on Win32, as OLE is one of the core services provided by the Windows API. Without understanding the differences involved here, you don't have much hope of succeeding in any way here.

    What you could do is to emulate the RPC calls of Win32/NT, from what I remember, this is pretty standard RPC, and use DCOM to automate the Win32 Applications from a second machine. But DCOM is only COM and not completely OLE, so you're setting yourself up for lots of pain here. A second solution would be to install Perl on the Win32 machine and just use that. Not much pain involved here. You also could use the Openoffice.org automation, but their document model is horribly broken and really ugly to use.

      Thanks.

      If we put OLE and ActiveState on an XP box, but the 'brains' and driving logic had to live on the linux side, what communication protocol would you recommend for the 'nix machine to ask the XP machine to do OLE actions and pass data back and forth?

      We would be seeking a protocol that is (1) friendly for a developer team that has never done this before, (2) relatively easy to set up, (3) robust, and (4) NOT handrolled.

      Any such thing exist?

      Thank you very much.

        Don't do a tightly coupled system. Pass RTF files, CSV files or whatever from the Linux side to the Win32 side, and have a Perl program monitor the drop directory. Then import the data into Office, munge it and spit it out again.

        Another (bad) idea would be to push over actual Perl code to be executed instead of data files, but if you already look in that direction, consider a database to handle outstanding jobs etc. You will have to have Perl code on the Win32 machine in any way, and I would try to avoid any fancy RPC scheme in favour of file based transfer or DB based transfer, where the advantages and disadvantages of both are to be weighed.

        You obviously haven't done much research in the direction, so here are some dire warnings:

        1. Office is single user. If you have more than one process trying to automate things, you are asking for much trouble.
        2. You might be well better off to use SpreadSheet::WriteExcel or simply distributing .pdf files or csv files instead of trying to produce them via OLE.
        Give SOAP/XMLRPC a chance. It is very easy to handle - if you dont mind about performace. Check: http://soaplite.com/features.html In one of my former project I used xmlrpc - If you have fixed IPs and no transaction handling it is really one of the easiest 'middlewares' i ever used.
Re: Win32::OLE, TPJ#10, linux
by saintmike (Vicar) on Sep 06, 2004 at 17:54 UTC
    Check out this article on how to remote-control Photoshop on a Win32 box from a Linux box using Win32::OLE and SOAP::Lite. It's written in German, but the listings should be self-explanatory.
Re: Win32::OLE, TPJ#10, linux
by tachyon (Chancellor) on Sep 06, 2004 at 11:16 UTC

    Win32::OLE is extremely tightly coupled to Windows. Essentially the C code in the OLE XS simply provides you access to the native Win32 OLE API. For example one of the first includes is #include <windows.h> ;-)

    What is it you want to do? If the (guess) task is to read/write to an Access database or similar they may be other options.

    cheers

    tachyon

      Sadly we need native Windows actions on native Windows objects and files -- we wish it were just Access (and could sue DBI) or Excel (and use Spreadsheet::WriteExcle). Sadly it is more full-blown and windows painful.

      Thank you very much.
Re: Win32::OLE, TPJ#10, linux
by Courage (Parson) on Sep 06, 2004 at 13:04 UTC
    I am not very sure, but as long as there exists WinE or Win4LIN, so you can even start MS-Office application under Linux, so it could be possible to easily adopt Win32::OLE for Linux.
    But this task will require a bit patching of Win32::OLE.
    I have experience with Win32 more than with Linux, so my advices from Linux side are weaker.

    As another thought, you could try from another side: is there exist any other Linux software that will perform OLE actions from Linux? You could tie it with Perl et voila...

    As a third thought, you could write Perl(win32) layer so it will communicate with Linux Perl and perform Win32::OLE commands by any given protocol (start with simple "eval" then grow to some kind of RPC or XML or something)

      Forget about win4lin ... I tried to write an Perl/Tk app, which worked under win32 as well as linux. So I gave win4Lin a chance (to emulate win98 under linux) - I had to 'reboot' win98 all the time ... I think it is supposed to work win word or excel quite all right but my experience with ole and tk is not too good.
        I hope you'll succeed this way, otherwise go and seek another wisdom here :)
Re: Win32::OLE, TPJ#10, linux
by bsdz (Friar) on Sep 06, 2004 at 16:17 UTC
    SOAP::Lite is definitely the way to go, maybe create a wrapper module, MyMod, around your Win32::OLE stuff or maybe use Win32::OLE directly then write a simple service script such as: -
    use SOAP::Transport::HTTP; my $server = SOAP::Transport::HTTP::Daemon ->new(LocalAddr => '192.168.0.1', LocalPort => 666) ->objects_by_reference('MyMod') ->dispatch_with( {'http://192.168.0.1/MyMod' => 'MyMod'}, ); $server->handle;
    the "objects_by_reference" part is very important since Win32::OLE objects are quite complicated, you must also use SOAPs HTTP Transport otherwise "objects_by_reference" won't work. then write your client script like: -
    use SOAP::Lite # trace => [ all, -transport ], dispatch_from => 'MyMod', uri => 'http://192.168.0.1/MyMod', proxy => ['http://192.168.0.1:666', timeout => 6000] ;
    this would be equivalent to "use MyMod" in your client.
Re: Win32::OLE, TPJ#10, linux
by dpavlin (Friar) on Feb 11, 2005 at 19:00 UTC
    You don't really need Windows machine. How to install Win32::OLE under Linux?

    However, disadvantage of that method is that you have whole another emulated machine (which might be on Linux and chrooted, but still a emulated Windows machine). On the bright side, you don't have to have another windows or fight with system administrators about installing that non-standard perl on Windows boxes.


    2share!2flame...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-19 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found