Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Python from Perl, Perl/Win from Perl/*nix

by punkish (Priest)
on Nov 09, 2005 at 15:48 UTC ( [id://507104]=perlquestion: print w/replies, xml ) Need Help??

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

here is the whole story.

I am writing a boatload of ETL scripts that will be loading data into Oracle (see Automating data loading into Oracle. Most all this work has to be done on a *nix box. Except, one task requires some transformation work that can only be performed on a Windows box. This is because of proprietary COM objects that will manipulate spatial data. Additionally, the official support for scripting these COM objects is only via Python, although the docs state that any scripting language "that supports COM using IDispatch" (which includes Perl) can be used). I don't have more details on this at this time, but my intent is to use Perl as much as possible. In case I am not able to use Perl, I might just end up using Python for that specific task. Hence...

I defintely will need to call a program on a Win box from a program on the *nix box. I might have to call Python on Win from either Perl on Win or Perl on *nix.

Phew.... any insights much appreciated.

--

when small people start casting long shadows, it is time to go to bed
  • Comment on Python from Perl, Perl/Win from Perl/*nix

Replies are listed 'Best First'.
Re: Python from Perl, Perl/Win from Perl/*nix
by gawatkins (Monsignor) on Nov 09, 2005 at 17:07 UTC

    You could set up the windows portion of the task as a XML web service. That would provide both a method of retrival and some level of security. In lieu of a web service, you could us this as a CGI script that generates either a web page or download file when called. You could access the web server from the *nix box via www::mechanizeor lwp::useragent. I currently do this from one windows box to another.

    Thanks,
    Greg W
Re: Python from Perl, Perl/Win from Perl/*nix
by idsfa (Vicar) on Nov 09, 2005 at 16:01 UTC

    Since you need to remotely run an as-yet undetermined program on a Windows box, I'd recommend that you install cygwin on the windows box and set it up to accept ssh connections. Then you can use Net::SSH2 to do whatever you would like. True, it's sort of a sledgehammer to kill a fly, but it will allow you to be more flexible until your requirements are set.

    Don't use the cygwin perl though ... just don't


    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon
Re: Python from Perl, Perl/Win from Perl/*nix
by duff (Parson) on Nov 09, 2005 at 16:02 UTC

    Mount the Windows box's disk on the unix box and use CIFS (samba) and the filesystem to communicate between the two. Have a driver program on the windows box that looks in an "inbox" folder for new stuff to do. This driver program would be the windows equivalent of a daemon--always running. When it sees files in the inbox, it processes them (by running the specialized software) and puts the result in an "outbox" folder. Also, have a program on the unix box watch the outbox and do whatever is appropriate to the files that show up there.

      I have always felt that polling ("pull") solutions a last resort whenever a semaphore or other message system ("push") solution can be used. Pull solutions pretty much always use up more CPU time and RAM as you have to be always running, looking for something periodically. Conversely, a push solution means we only load what we need to load, when it is demanded of us, and we use literally no CPU time until that time.

      Thus, I much more liked the ssh solution above than using a disk like this. If you are going to write a daemon anyway, have it listen on a port, and wait for communication on that port. Then it can do stuff based on what it receives there. This will mean more RAM used (but it can be swapped out if it's not active very much), but no CPU time (the OS will leave your app asleep until something comes in on the designated port). Especially in perl - perl makes writing client/server TCP apps very easy, not like C. So take advantage of that.

Re: Python from Perl, Perl/Win from Perl/*nix
by BrowserUk (Patriarch) on Nov 09, 2005 at 17:00 UTC

    Regardless of what method you use, you will require a program or demon running on the windows box to recieve or notice the data, and run the windows program. You could use a rsh shell or a SOAP daemon or a program that monitors a directory, but something has to be there waiting.

    And since you also have yet to write the script that interfaces with the COM object, why not combine the two and have the script open a port, wait for the inbound data, process it through the COM object and then return the response. Either Perl or Python are fine for that.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Python from Perl, Perl/Win from Perl/*nix
by spatterson (Pilgrim) on Nov 09, 2005 at 16:30 UTC
Re: Python from Perl, Perl/Win from Perl/*nix
by mikeock (Hermit) on Nov 09, 2005 at 16:03 UTC
    My only experience is taking python scripts and re-implementing them back into perl.

Log In?
Username:
Password:

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

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

    No recent polls found