Click to See Complete Forum and Search --> : Calling a script from another site
mawnet
04-09-2004, 10:02 AM
Hi all
I need to call a script that is hosted on another web site, from within my perl script.
To call a local script I can probably use
require "myscript.asp?query=1";
but how can I call an ASP script on another web site?
IE
require "www.thehost.com/TheScript.asp?query=1";
... but this does not work :-(
Any help is apreciated!!!
Marc
Scriptage
04-10-2004, 02:15 AM
this should work but I aren't sure.
use LWP::Simple qw(get); # ? qw(:get);
my $doc = get("www.thehost.com/TheScript.asp?query=1");
# The output of the page will be stored in $doc
Regards
mawnet
04-10-2004, 05:01 AM
Scriptage
Thank you for your hint, but I was unable to get it to work.
I can't even use the declaration only without getting an error.
I tried both
use LWP::Simple qw(get);
and
use LWP::Simple qw(:get);
and even only
use LWP;
they all fail :-(
My script needs to run on the BTOpenWorld web server, perhaps they have not implemented the LWP library???
Any other suggestion ?
Regards
Marc
Nedals
04-10-2004, 04:58 PM
Try this:
print "location:http://www.thehost.com/TheScript.asp?query=1\n\n";
mawnet
04-11-2004, 07:28 AM
Thanks Nedals,
It seems to work once, at least when I call the script directly within a web browser. In future it needs to be called from another script of my web host, not sure if this will work then too...
When I call it however two times
print "location:http://www.thehost.com/TheScript.asp?query=1\n\n";
print "location:http://www.thehost.com/TheScript.asp?query=2\n\n";
it does not display the result of the second query and I think the second query is not called at all, only the first. Is this normal ?
Is it possible to have both queries executed ?
Regards
Marc
Nedals
04-11-2004, 03:04 PM
I don't understand...
From your HTML page, in the browser, you will call, via POST or GET, script1.cgi.
In that script, using 'print location:...' you will call script2.cgi.
This will then return a page to your browser. So it is not going to process that second 'query'.
Perhaps more detail on what you are trying to accomplish will point to a different solution!
mawnet
04-11-2004, 05:10 PM
Nedals
My script is called from a web site with different parameters
&option1=1&option2=2&option3=3
In my script I loop now through all defined options and extract the values.
Then I need for every option defined to call an external link
IE
www.thehost.com/TheScript.asp?query=1
www.thehost.com/TheScript.asp?query=2
www.thehost.com/TheScript.asp?query=3
etc
The return value of the script is not as important, it just needs to be called.
Regards
Marc
Nedals
04-11-2004, 05:48 PM
I'm not sure how to solve your problem.
It would seem that the best way would be to sent ALL the query's at one time to that second script, process them, and have that script send all the results at one time.
Best Guess :)
ps: post changed a bit?
mawnet
04-12-2004, 03:00 AM
Nedals
I found an alternative in not calling the other script, but submitting the query by e-mail (using sendmail).
I am still testing to see if this works.
But thanks for your help, it was greatly appreciated.
Regards
Marc
>>>ps: post changed a bit?
Keep it simple
:)