curl-library
libCurl equivalent to command line --ftp-ssl ??
Date: Mon, 21 Jun 2004 15:09:01 -0700
what is the libcurl equivalent to the command line switch --ftp-ssl? I
am trying to connected to an ftp server over ssl and i would like to
write a program in perl to do that. I am not too sure of the actual
options that i need to have set. So far the following is what I have
and its denying my access:
#!/usr/bin/perl
use strict;
no strict 'subs';
use WWW::Curl::easy;
$| = 1;
use IO::File;
my $url = "ftp://ftp.thesite.com/test.txt";
my $body;
sub chunk {
my ( $data, $pointer ) = @_;
${$pointer} .= $data;
return length($data);
}
my $fh = new IO::File( "the_test_file.txt", 'w' ) or die " cannot
create new file $!";
#init curl session
my $curl = WWW::Curl::easy->new();
my $code = $curl->setopt(CURLOPT_USERPWD,"****:****");·
$code = $curl->setopt( CURLOPT_TIMEOUT, 30 );
$code = $curl->setopt( CURLOPT_URL, $url );
$code = $curl->setopt(CURLOPT_FTP_SSL,CURLFTPSSL_ALL);
$code = $curl->setopt(CURLOPT_SSL_VERIFYPEER,1);
$code = $curl->setopt(CURLOPT_SSL_VERIFYHOST,1);
$code = $curl->setop(CURLOPT_SSLVERSION,2 );
$code = $curl->setopt( CURLOPT_WRITEFUNCTION, \&chunk );
$code = $curl->setopt( CURLOPT_FILE, \$body );
$code = $curl->perform();
my $bytes = $curl->getinfo(CURLINFO_SIZE_DOWNLOAD);
print" code10: $code\n";
#print " bytes: $bytes\n";
#print " body: $body\n";
#$fh->write( $body, $bytes ) or die " cannot write to file: $!";
$fh->close();
any help would be appreciated. thanks!!
Swati
Received on 2004-06-22