CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Intercepting script output?



May 2, 2000, 3:27 PM

Post #1 of 3 (865 views)
Intercepting script output? Can't Post

The Setup:
When called from the browser, script-A performs some action and outputs some html to the browser.

The Question:
Is it possible for script-B to call script-A and intercept the html that script-A would send to the browser and perform actions on that html and then send it to the browser itself?

Special Note: Script-A is hosted elsewhere and I am not able to modify it.

[This message has been edited by monocle (edited 05-02-2000).]

Administrator / Moderator

May 3, 2000, 8:09 AM

Post #2 of 3 (865 views)
Re: Intercepting script output? [In reply to] Can't Post

This sounds like a perfect candidate for LWP.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

use LWP::UserAgent;
$webagent = new LWP::UserAgent;
$url = "";

$request = new HTTP::Request(GET => $url);
$response = $webagent->request( $request );

if ( $response->is_success ) {
# do something with $response->content -- this contains the full html code for the request

If you need to post to the form in order to receive the html code, search the forum for this -- posting via LWP has been addressed quite a few times.

Good luck!


May 4, 2000, 4:29 PM

Post #3 of 3 (865 views)
Re: Intercepting script output? [In reply to] Can't Post

I thank you for the code, but I get an error:
Can't locate LWP/ in @INC (@INC contains: /usr/lib/perl5/i686-linux/5.00404 /usr/lib/perl5 /usr/lib/perl5/site_perl/i686-linux /usr/lib/perl5/site_perl .) at /www/cgi-bin/random.sbe.playlist.cgi line 45.

This is the code that sorrounds the error ("Line XX" is not in the actual script. Only here to point out supposed line of error.):
Line 43: $| = 1;
Line 44:
Line 45: use LWP::UserAgent;
Line 46: $webagent = new LWP::UserAgent;
Line 47: $url = "";
Line 48:
Line 49: $request = new HTTP::Request(GET => $url);
Line 50: $response = $webagent->request( $request );

My sys admin assures me that the proper modules were installed but can offer no support on the script itself. Am I missing something? Do I need to add a path to the call for LWP on line 45?

If anyone can help, it would be great.

Hear great techno music by Monocle at


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives