Forum Moderators: coopster & phranque

Message Too Old, No Replies

Calling CGI script from a different server

Problems with call a script across servers

         

newhorizonz

7:13 pm on May 11, 2004 (gmt 0)

10+ Year Member



OK here's the deal!

I run a number of scripts on Server A which need to be called from other Servers (say B, C D .....). Now on Server A there are a lot of other virtual servers and by careful manipulation I can create an ScriptAlias path (cgi-bin2) to enable all these other virtual servers to include virtual the script calls as though they existed within their own cgi-bin's.

But out in the outside world there are really only the followjng ways to initiate the scripts to display the results back in the various web pages on these servers:

(1) #EXEC..... - not a good idea due to the security issues plus the fact that a lot of ISP's disable this call plus the fact that I cannot pass parameters.

(2) Call the script by a direct address and have a page template per site back on Server A to keep the blended theme - too much agro if the user wants to change their theme or layout.

(3) call the script from the user site in a frameset or iframe - probably OK but on some occasions gives unruly looking screen outputs with another scroll bar

Is there any way to call a scriopt (preferably with a parameter across servers? I did come across something called CGICALL which claims to do all this - call one script from within another across servers and allow manipulation of the results but emailing the author - he no longer supports or even runs it.

Help please?

volatilegx

8:09 pm on May 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try using LWP. Here's some code:

[pre]
use LWP::UserAgent;
$URL = 'http://www.yourdomain.com/cgi-bin/scriptname.cgi';
$params = '?param1=foo&param2=bar';
$ua = new LWP::UserAgent;
$re = new HTTP::Request(GET => $URL . $params);
$response = $ua->request($re);
$content = $response->content;
[/pre]

newhorizonz

10:53 pm on May 11, 2004 (gmt 0)

10+ Year Member



Thanks - I am new to LWP module so are you saying that I can insert this code into a script on one server and this will call a script on another server?

Can you point me to any examples of this in a working situation?

volatilegx

1:24 pm on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks - I am new to LWP module so are you saying that I can insert this code into a script on one server and this will call a script on another server?

Yep.

Can you point me to any examples of this in a working situation?

Examples? Hmm. Not where you would actually be able to see the code. However, I can point you to the LWP cookbook [search.cpan.org], which is a guide on how to use LWP.

The code I gave was adapted from my own working code. It should work :)