J
joemacbusiness
Hi All,
I want to use http POST to push several gzipped files
to another apache server. We need to use this since our
customers only allow access to port 80, so no ssh and no ftp.
I am using perl LWP modules for this.
The problem is that it seems like the POST works like a get (pull)
when I really want it to *push* the many *gz files to another
host.
Here is the code I have so far. This POST works like a "get".
========================= snip =========================
use HTTP::Request::Common qw(POST);
use LWP 5.64; # get the most recent stuff.
$ua = LWP::UserAgent->new;
#########################################################
# this builds a list of files that need to be transferred.
# it creates a local file: /tmp/zipped.list
#########################################################
#
my $req = HTTP::Request->new(POST => 'http://somehostname.company.com/
~user/zipped.list');
$req->content_type('text');
open(F,">/tmp/zipped.list") || print "cannot open /tmp/zipped.list";
#binmode F;
print F $ua->request($req)->content;
close(F);
#########################################################
# this loops through the list and (supposedly) copies the
# files **to** the desthost (ie a push).
# But it really pulls the files down from the desthost
# I want it to push the files to desthost.
#########################################################
#
my $infile = "/tmp/zipped.list";
open(FILELIST,"$infile") || print "cannot open $infile $!";
my @filearray = <FILELIST>;
close(FILELIST);
chdir("/tmp/shipping");
my $pwd = `pwd`;
print " ================================ working directory = $pwd \n";
foreach my $fname (@filearray){
chomp($fname);
print "transferring $fname .... \n";
my $req = HTTP::Request->new(POST => "http://desthost.company2.com/
~user/$fname");
$req->content_type('application/gzip');
open(F,">/tmp/shipping/$fname") || print "cannot open /tmp/
shipping/$fname";
binmode F;
print F $ua->request($req)->content;
close(F);
}
========================= end snip ======================
How do I make the code PUSH the gzipped files to desthost?
This assumes that I have permission on desthost for ~user, which I do.
Any help would be appreciated,
Thanks, Joe M.
I want to use http POST to push several gzipped files
to another apache server. We need to use this since our
customers only allow access to port 80, so no ssh and no ftp.
I am using perl LWP modules for this.
The problem is that it seems like the POST works like a get (pull)
when I really want it to *push* the many *gz files to another
host.
Here is the code I have so far. This POST works like a "get".
========================= snip =========================
use HTTP::Request::Common qw(POST);
use LWP 5.64; # get the most recent stuff.
$ua = LWP::UserAgent->new;
#########################################################
# this builds a list of files that need to be transferred.
# it creates a local file: /tmp/zipped.list
#########################################################
#
my $req = HTTP::Request->new(POST => 'http://somehostname.company.com/
~user/zipped.list');
$req->content_type('text');
open(F,">/tmp/zipped.list") || print "cannot open /tmp/zipped.list";
#binmode F;
print F $ua->request($req)->content;
close(F);
#########################################################
# this loops through the list and (supposedly) copies the
# files **to** the desthost (ie a push).
# But it really pulls the files down from the desthost
# I want it to push the files to desthost.
#########################################################
#
my $infile = "/tmp/zipped.list";
open(FILELIST,"$infile") || print "cannot open $infile $!";
my @filearray = <FILELIST>;
close(FILELIST);
chdir("/tmp/shipping");
my $pwd = `pwd`;
print " ================================ working directory = $pwd \n";
foreach my $fname (@filearray){
chomp($fname);
print "transferring $fname .... \n";
my $req = HTTP::Request->new(POST => "http://desthost.company2.com/
~user/$fname");
$req->content_type('application/gzip');
open(F,">/tmp/shipping/$fname") || print "cannot open /tmp/
shipping/$fname";
binmode F;
print F $ua->request($req)->content;
close(F);
}
========================= end snip ======================
How do I make the code PUSH the gzipped files to desthost?
This assumes that I have permission on desthost for ~user, which I do.
Any help would be appreciated,
Thanks, Joe M.