Forum Moderators: coopster & phranque

Message Too Old, No Replies

How to transfer the input buffer from script1 to script2

print <STDIN>?

         

WWMike

8:38 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



How would I go about passing along the form fields submitted to my own CGI script to a different CGI script on another server that I have no control over?

I don't want to append my fields to a URL and use the GET method for the second script. I want to invisibly transfer my fields to the second script by POST.

I tried:

read ( STDIN, $buffer, $ENV{CONTENT_LENGTH} );
print STDIN $buffer;
print "Location: [anotherdomain.com...]

but that didn't seem to make the fields available to the second script.

How can I stuff the input buffer so that the second script can be pre-populated?

KevinADC

12:49 am on Aug 1, 2005 (gmt 0)

10+ Year Member



possibly using the LWP module. See if you can figure it out:

[search.cpan.org...]

I am not familiar with how to use the module myself.

WWMike

2:28 am on Aug 1, 2005 (gmt 0)

10+ Year Member



I've never used that before and I'm not even sure that it's actually posting but if it is, it appears to be doing it in a parallel process behind the scene instead of transferring control over to that second script in the browser like doing a print "Location:http://domain.com/script.cgi?parm1=abc" would. Any ideas?

KevinADC

5:52 am on Aug 1, 2005 (gmt 0)

10+ Year Member



sorry, I have no further ideas.

bennymack

2:35 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



I think what you're looking for is WWW::Mechanize. It's more for automating form submissions and stuff whereas LWP is for scraping up webpages.

SeanW

3:38 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



Mech is built on LWP, it just automates some of the tasks you'd normally do such as finding links.

To answer the OP, if you want to submit the form to another site using a POST, you'll have to have your CGI do it and then send the output to the screen. You'd also have to fix up the links on the returned webpage.

LWP or Mech will do it fairly easily, though it's not one of those things I'd ever want to have to do.

Sean

WWMike

5:07 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



I'm getting a 500 error on:

use WWW::Mechanize;

so I guess it's not installed on my server.

It looks like it will do the job but before I ask my host to install it, can anyone tell me if it will simulate the same thing as:

print "Location: [domain.com...]

I want the browser to actually display whatever the resulting page is after submitting that form just as if I did it manually.

Keep in mind that the resulting page may actually be dynamically generated from the script and therefore won't actually have a physical URL that I can manually traverse to.

Will it physically change pages in my browser?

rocknbil

8:31 pm on Aug 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to invisibly transfer my fields to the second script by POST.

Again, curl is probably your answer.

$result = `curl 'param1=a&param2=b' $externalURL`;

print "content-type: text/hml\n\n";
print "$result";
exit 0;

If the external URL just outputs standard HTML, this will work.