FTP PUT with proxy?

D

dtfcalibrator

I've been struggling with this forever now. Hopefully someone can help

Lets say you have the following:

proxy server: my.proxy.com
proxy username: proxyuser
proxy password: proxypassword
ftp server: my.ftp.com
ftp username: ftpuser
ftp password: ftppassword
file to PUT: myTextFile.txt


I've been trying to use LWP::UserAgent, HTTP::Headers, and
HTTP::Request without any real success.

Here's where I gave up (I'm not working on proxy auth yet):
use File::stat;
use LWP::UserAgent;

$stats = stat("myTextFile.txt");
$fileSize = $stats->size;
$ua = LWP::UserAgent->new;
$ua->proxy(['http', 'ftp'], 'http://my.proxy.com');
$header = HTTP::Headers->new;
$header->authorization_basic("ftpuser", "ftppassword");
open(FH, "myTextFile.txt");
read(FH, $buf, $fileSize);
$req = HTTP::Request->new("PUT", "ftp://my.ftp.com/myTextFile.txt",
$header);
$req->content($buf);
$response = $ua->request($req);
 
U

usenet

I've been struggling with this forever now.

I feel your pain. I've got a proxy server at work that hates me and
conspires to cause problems with LWP (and ncftp and wcftp and lynx) no
matter how many configuration settings I futz around with.

However, cURL (http://curl.haxx.se/) seems to punch through just fine
(I actually use cURL to pull down my CPAN updates using the CPAN.pm
module).

There's a nice CPAN interface module to libcurl:

http://search.cpan.org/~crisb/WWW-Curl-3.02/Easy.pm.in

(but this is a rare instance when I wouldn't object to using a system
command from Perl).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top