ftp/Connect.pl

#///////////////////////////////////////////////////////////////////////////////////
#//
#// DownloadFile (v0.1 10. April 2006)
#//
#// Purpose:
#//   Downloads a single file from one remote server to your local computer.
#//
#//
#// Copyright (c) 2004 - 2006 by SmartFTP.com
#//
#///////////////////////////////////////////////////////////////////////////////////
use strict;
use Win32::OLE;
use Win32::OLE::Variant;
$| = 1;

package Test;
my $ftp = Win32::OLE->new('sfFTPLib.FTPConnectionMTA');

$ftp->{Host} = "ftp.smartftp.com";
$ftp->{Port} = 21;
$ftp->{Username} = "anonymous";
$ftp->{Password} = "test\@test.com";
$ftp->{Passive} = 1;
$ftp->{MLST} = 1;
$ftp->{Protocol} = 0;

my $ret = $ftp->Connect();
if($ret == 0)
{  
    print("Connected to server\n");
    if($ftp->ChangeDirectory("/SmartFTP") == 0)
    {
        print("ChangeDirectory() successful.\n");
        if($ftp->DownloadFile("License.txt", "License.txt", 0, 0) == 0)
        {
            print("DownloadFile() successful.\n");
        }
        else
        {
            print("DownloadFile() failed.\n");
        }
    }
    else
    {
        print("ChangeDirectory() failed.\n");
    }
}
else
{
    print("Connect failed.\n");
}

 
© SmartSoft Ltd.