Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 4th, 2000, 06:02 PM
Ray2 Ray2 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 0 Ray2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have 2 sites (A and B), and I must call a script on site B from site A, get the results on A, and display them.

I wrote a script (on site A) that I call with a POST method from a form on a page on the same site.
This script receives the arguments, calls the script on site B, receives the answer, and displays it.
The call of the script on B works, but the arguments sent to it are never received.
So it's useless!!

Would somebody see what I did wrong on passing the arguments?

The script is as follows:

#!/usr/bin/perl
#######################################################
# remote.cgi : calling remote script
#######################################################

require HTTP::Request;
require LWP::UserAgent;
require HTTP::Headers;

&parsedata;
$url = $form{'url'};
$method = $form{'method'};
if ($method eq '') { $method = 'POST'; }
my $ua = LWP::UserAgent->new;
$h = new HTTP::Headers;
foreach $key (keys %form)
{
if ($key ne 'url' && $key ne 'method')
{
$h->push_header($key => $form{$key});
}
}
my $request = HTTP::Request->new($method => $url, $h);
my $response = $ua->request($request);
$rc = ($response->is_success) ?
$response->content:
$response->error_as_HTML;
print "Content-type: text/htmlnn$rc";

sub parsedata
{
my $buffer = "";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
my @pairs=split(/&/,$buffer);
foreach my $pair (@pairs)
{
my ($name,$value) = split(/=/,$pair);
$value =~ s/+/ /g;
$value =~ s/~!/ ~!/g;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/[]//g;
push (@data,$name);
push (@data, $value);
}
%form=@data;
%form;
}
###### end of script ###########


Thanks for your help!



Reply With Quote
  #2  
Old December 6th, 2000, 03:44 AM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Start here -> http://www.devshed.com/Talk/Forums/Forum6/HTML/000387.html and check out this simple example.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > calling a script on another server


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway