PERL CGI question

kuki18
kuki18 used Ask the Experts™
on
i need to call a script from another server from a script i write how can i do this??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007
Commented:
Depends on the protocol you have available.

Is it HTTP, SOAP, telnet, etc, etc......
system('/path/to/ssh user@remoteserver /path/to/script');

you also my try perl's Net::SSH module.
Commented:
The way that I usually do this is to make the script on the other server web-accessible; that is, make it a Perl/CGI script on the other server.  This script should make sure that it only accepts your new script as the "HTTP_REFERER", meaning that nobody else can call your script from their web pages.

Next, in the new script that you're writing, you'll need to use the LWP module, something like this:

use strict;
use LWP::Simple;

my $html = get('http://192.168.1.1/cgi-bin/your_script.cgi');

Any value returned from the script will be stored in the $html scalar (variable).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial