Link to home
Start Free TrialLog in
Avatar of elpmet
elpmet

asked on

Script to forward input to another CGI script...?

I'm trying to write a CGI script in Perl, that just forwards client's request to an actual remote CGI program that does the actual work. And it also receives the resulting data from the remote script. Can we do this?

For example,

1) The front-end HTML (say, "front.html") sends Name and Email to a script (which I'm trying to write;  filename is, say, "middle.cgi").

2) This script ("middle.cgi") confirms/tests the inputs, and forwards to the remote CGI script (say, "end.cgi").

3) "end.cgi" processes what it received from "middle.cgi" and dumps its result back to "middle.cgi".

4) "middle.cgi" dumps a simple confirmation message to the client browser.

I'm wondering if you could write me a basic, but working script ("middle.cgi") as a head-start.  Thanks a million for your help!  (I'm running Linux on my box)

elpmet.
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nettrom
nettrom

If your remote CGI script runs on a web server and is only accessible through HTTP, look into lib-www-perl (LWP) (http://www.linpro.no/lwp/).   LWP::Simple should be all you need.
yes, and you can find small working examples at the cpan website
Avatar of elpmet

ASKER

ahoffmann,

Thanks for your help.  But the "front.html" script is a simple HTML file which sends a request to the "middle.cgi" script which then simply forwards what it received to the "end.cgi" which dumps the result back to "middle.cgi".  Each script is located on a different web server.  Can we still do this without using network modules?


nettrom, and bebonham,

Thanks for your suggestion, but is there any other way without downloading the utilities?  (or can you point me to an exact location for the module?  I went to the site, but I couldn't find documentation on how to use it either.  Also, can I still install that without having the root access?  I'm sorry for being a newbie in unix/perl)
You should be able to run modules without having to install them.  Perl will, IIRC, also look for modules in the current working directory (in other words, where the script is run from).  It's also possible to manipulate Perl's list of directories to search for modules at run-time, but that topic is beyond my current knowledge of Perl.

Perl can of course access system tools, so you could use lynx or wget if either of those are installed on your system.  To retrieve the source of a document through lynx you call it with 'lynx -source URL', so in Perl you could do:

my($url) = "http://www.yahoo.com";
open(MYURL, "lynx -source $url|" or die "Unable to open file: $!";
my(@content) = <MYURL>;close(MYURL) or die "Unable to close file: $!";then you have the content of the document found in the array @content.
Avatar of elpmet

ASKER

Thanks, folks, and bebonham,

I've printed out the doc and am going to write a test program to see how it goes.  I will come back soon.  Thanks for for your help!

elpmet.

In the meantime, I have another CGI question as follows (please help if you know anything about it...): https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=cgi&qid=20187827
elpmet,

Did you get the solution you were looking for?

If so, please delete this question & free up your points, or award the points to the answer you found most useful.

Thanks,
elpmet,

You have the following 2 questions open in the "CGI Programming" topic area.
These questions have been open for more than 2 months now.


https://www.experts-exchange.com/jsp/qShow.jsp?ta=cgi&qid=20187827 (09/25/01)
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cgi&qid=20186615 (09/23/01)

Please go ahead and close these questions at the earliest.

Thanks.
elpmet,

                     Did you get the solution you were looking for?

                     If so, please delete this question & free up your points, or award the points to the answer you found
                     most useful.

                     Thanks,
Points reduced for split.  Comment from expert accepted as answer.  bebonham, look for your question in this topic area.

Computer101
E-E Moderator