CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
An LWP::USERAGENT GET problem

 



pegasus
Novice

Dec 29, 2002, 9:52 AM

Post #1 of 6 (952 views)
An LWP::USERAGENT GET problem Can't Post

I have a tar file on my server, containing perl scripts, javascripts and images. I get people to install a script on their site which then runs a LWP::USERAGENT GET comand to transfer the file from my machine to theirs before recovering the files to their machine.

However, at present, it seems to be dropping the graphics from the end of the transfer. (Trying it offline on ActiveState/Windows perl, I end up with 1199 bytes less on the transfered tar than original file ... and measuring the original tar from GIF89PGI89 its 1199!! bytes)

Any suggestions? (I am using BINMODE when I copy the downloaded tar back out to server)

perlguru@pegasusvideo.plus.com


uri
Thaumaturge

Jan 3, 2003, 11:33 PM

Post #2 of 6 (934 views)
Re: [pegasus] An LWP::USERAGENT GET problem [In reply to] Can't Post

does the url start with ftp:? if so, it could transfer the file in ascii mode and if the two platforms are different (unix vs. winblows) then you could lose bytes due to the line ending issues.


pegasus
Novice

Jan 4, 2003, 9:15 AM

Post #3 of 6 (931 views)
Re: [pegasus] An LWP::USERAGENT GET problem [In reply to] Can't Post

No its between Unix server to Unix server and doesn't have ANY http: or ftp: type protocol - or at least, not specifically set. (Its working on a Windows test bed transferring files from C: to G: at present)


davorg
Thaumaturge / Moderator

Jan 4, 2003, 11:31 PM

Post #4 of 6 (927 views)
Re: [pegasus] An LWP::USERAGENT GET problem [In reply to] Can't Post

How do you run a "get" without a protocol?

Can you show us the relevant part of the code.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


pegasus
Novice

Jan 5, 2003, 9:58 AM

Post #5 of 6 (921 views)
Re: [pegasus] An LWP::USERAGENT GET problem [In reply to] Can't Post

$ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => 'http://127.0.0.1/files.tar');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {

open (FILES,">store area");
print FILES$res->content;
close(FILES);
}

The code I was using was similar to this. It seemed to load part of the code across (its about 800kB), but it seemed to cut off early.

I now think I'll copy a list of files to the slave server, and get each file individually.


Paul
Enthusiast

Jan 5, 2003, 1:43 PM

Post #6 of 6 (920 views)
Re: [pegasus] An LWP::USERAGENT GET problem [In reply to] Can't Post

First add error checking to your open statement.

The cause of your main problem is that you need:

binmode FILES;

....before:

print FILES $res->content;

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives