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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



monocle
User

May 2, 2000, 3:27 PM

Post #1 of 3 (421 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).]


Jasmine
Administrator / Moderator

May 3, 2000, 8:09 AM

Post #2 of 3 (421 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 = "http://www.yourdomain.com/cgi-bin/whatever.cgi";

$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
}
</pre><HR></BLOCKQUOTE>

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!


monocle
User

May 4, 2000, 4:29 PM

Post #3 of 3 (421 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/UserAgent.pm 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 = "http://studio.mp3.com/cgi-bin/artist-admin/station_admin.cgi?action=list";
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.

Thanks,
Monocle
Hear great techno music by Monocle at http://www.mp3.com/monocle

 
 


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

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