Re: Run Perl script on remote server
by blue_cowdawg (Monsignor) on Feb 14, 2013 at 15:51 UTC
|
- Scripts reside in server A (Has Perl modules installed)
- Webserver is B (no Perl and policy said we can't install)
What sort of environment are you running in that won't allow Perl to be installed (or doesn't already have Perl installed?)
Once solution to this would be to convert your scripts on Server A into a web service and communicate back to the PHP scripts running on Server B via JSON encoded messages or some such.
Take a look at the path_info() method of the module CGI for some ideas on how to implement this. It is a quick and dirty way of implementing something that sorta looks like a RESTFull service.
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
| [reply] [Watch: Dir/Any] [d/l] |
Re: Run Perl script on remote server
by daxim (Curate) on Feb 14, 2013 at 16:01 UTC
|
Simple: open a pipe to ssh.
Or run your Perl programs in a Web server, and write a PHP HTTP client for them (fopen, curl).
If that is not possible or sufficient, then you're looking for RMI/distributed computing (or conceptionally equivalent). If you have no idea where to start, simply run a Perl SOAP server and PHP SOAP client, SOAP sucks hairy donkey balls but at least it's painless in PHP. There are many more protocols (XML-RPC, JSON-RPC, Corba, …) and you can invent your own protocol (on top of sockets, on top of HTTP, …). | [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by necroshine (Acolyte) on Feb 14, 2013 at 16:09 UTC
|
I think you can use 'gearman' to spawn a job from PHP and receive a serialized result from PHP. After this you can use PHP::Serialization(CPAN) to deserialize or JSON to bring the results with Perl(JSON probably is more simple). Gearman site:
Off course you will need to install Gearman in A and B servers. If you can´t do this, you can use simple sockets to get results from PHP and finally process with Perl anyway.
| [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by jfroebe (Parson) on Feb 14, 2013 at 20:58 UTC
|
From what it sounds like is that you're trying to get around a PHP development mandate by, presumably, your employer. At least that's what is coming across to me. If that is the case, then you're better off making a business case for using Perl as well as PHP else you might be in a wee bit of trouble with the web server folk.
We definitely need a better description of what you're trying to accomplish so we can help you do the right thing, whatever that is. :)
| [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by Anonymous Monk on Feb 15, 2013 at 02:10 UTC
|
Whisper it quietly, but the easiest, most efficient and stable solution is probably to bite the bullet and re-write the script in PHP.
It should only take a couple of days to learn enough PHP to do this for most scripts.
I prefer Perl, but if someone wants to pay me to write PHP I'm up for it.
J.C.
| [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by Anonymous Monk on Feb 14, 2013 at 23:42 UTC
|
Set up server-A as a "FastCGI" host that is communicated-with by server-B using "mod_fastcgi" or its equivalent on Apache. "B" doesn't have to be generally accessible; only accessible to "A." | [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by igelkott (Priest) on Feb 15, 2013 at 00:27 UTC
|
Could package your Perl scripts on A with pp. Copy and run the package on B to get some benefit of Perl without actually installing.
Of course, this probably violates the "spirit" of the policy but may in fact be permitted.
| [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by karlgoethebier (Abbot) on Feb 14, 2013 at 19:19 UTC
|
I have a problem to understand this task.
Perhaps you can provide a more detailed example?
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
| [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by Anonymous Monk on Feb 14, 2013 at 21:14 UTC
|
Given the fact that I don't know the particulars...
Would it be possible to use reverse proxying to forward requests to Webserver B along to server A? Easy to implement if your environment supports it. | [reply] [Watch: Dir/Any] |
Re: Run Perl script on remote server
by Anonymous Monk on Feb 14, 2013 at 22:24 UTC
|
If speed is an issue, Create the page on server B as a template with specific DIVs labeled to hold the dynamic content.
Use AJAX and jQuery to load the html as a string from server B. Then insert the text into the appropriate DIVs using their labels.
Throw a nice loading gif as a placeholder and bam, good to go. No blank page while waiting for the AJAX loads. | [reply] [Watch: Dir/Any] |