[ back to toc ]

data exchange

Date: 2002/02/25 17:11

Hi Peter:

I am trying to send data to a script which is located outside out the
current server.
For example, http://mydomain.com/cgi-bin/myscript.cgi want to send "hello"
to http://yourdomain.com/cgi-bin/yourscript.cgi.
Ordinarily, I would just use "Location:
http://yourdomain.com/cgi-bin/yourscript.cgi?hello" to do that. But if I
do that, then the controll will be released from myscript.cgi to

Bascially the structure for myscript.cgi is


#Get variable

#save variable

#send data to yourscript.cgi

#display confirmation

print "Thank you for your submission.";

So, my question is Is there a way to send data to another
domain, and after that
the script can continue to run and finish the rest of the script? Because
once I use "Location" the script will be terminiated regardlessly, and
whatever comes after "Location" will not be

Any kind help you can offer is greatly appreciated!

Thank you very much!



If you send the header Location: along with the "Status: 302 Permanently
Moved" to the client the client will visit the other site. This is like
two experts standing in a line named Tom and John, and when you ask Joh a
question "A" he says: I do not know, you have to ask Tom the question "B".

This is not what you need. What you need is to ask the question "A" from
John and then John should ask the question "B" from Tom and tell you the
answer. Is it what you need, am I right?

In CGI world this means that the script running on mydomain should fetch
the result of the script on the machine yourdomain and then send to the
client the result it fetched.

To do this, to fetch HTML content of another page you can use the module
libwww. Look for this module.

You can also look at the program


to see a program, which fetches a web page without any external module.
This is not a CGI program, but a CGI program should do the same.


[ back to toc ]