If you want to get the size, modified date, etc. for the local files, you
can use stat().

perldoc -f stat

-----Original Message-----
From: Ken Cornetet [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 26, 2002 10:30 AM
To: 'Sidwell, Josh'; '[EMAIL PROTECTED]'
Subject: RE: Fileops


Here's how I do something similar...


$objFtp->cwd($ftpdir)
        or urp( "Could not CD to $ftpdir. Error: " . $objFtp->message() .
"\n" );

# Grab list of files

my @aryFiles = $objFtp->ls();

# Look through list finding newest

foreach my $strFile (@aryFiles) {
        $tmeModified = $objFtp->mdtm($strFile);
        if( $tmeModified > $tmeLatestMod ) {
                $strLatestName = $strFile;
                $tmeLatestMod = $tmeModified;
        }
}




-----Original Message-----
From: Sidwell, Josh [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 26, 2002 10:46 AM
To: [EMAIL PROTECTED]
Subject: Fileops


I am trying to create a file compare with a remote server through FTP to
check the file size and determine if I need to download a newer version of
the file.  Below is a snippet of code, showing the download.  I cannot
figure out how to take the hash with the size=value and compare it to the
local version of the file.

<snip>

# Create a new Win32::Internet object to perform the sync with
$INET = new Win32::Internet();

# Set the site/user/password information
$INET->FTP($FTP, $ftpsite, "anonymous", "[EMAIL PROTECTED]");

# Set the session to binary
$FTP->Binary();

# Change to the appropriate directory on the remote server
$FTP->Cd($remdir);

# Create an array with the names and sizes of the files in the remote
directory
# The "*" is a universal glob, and the "3" is the type of $FTP->List method
to
# call. See documentation for other alternatives
@files = $FTP->List("*",3);

# Print heading information for download section
print   "You are attempting to download the following files.\nAs each file
is accessed, it is compared against a\nlist of files which are already
present in your\ncurrent directory.\n\nIf the file exists, it will
report\nthe same information as it does when downloading.\n\n\n\n";

# Program main loop which prints out the name of the file, and its size
while it
# is being downloaded
foreach $file (@files) {
        select STDOUT;
        write STDOUT;
        $FTP->Get($file->{'name'},$file->{'name'},1);
        
}

# Format section that determines the layout for the results of our transfer
format STDOUT =
        @<<<<<<<<<<<<<<<        @>>>>>>>>>>>>>>>
        $file->{'name'}, $file->{'size'}        
.
</snip>

Joshua Sidwell
Network Engineer, CISSP
1400 S. Grand Ave
Santa Ana, CA 92705
(714) 796-8383
[EMAIL PROTECTED]

--------- Email Confidentiality Notice -------
The information in this email may be confidential, proprietary and/or
sensitive and is intended only for use by the entity or individual to whom
it is addressed.  If you, the reader of this email and/or its attachments,
are not the intended recipient, you are hereby notified that any
dissemination, distribution, publishing, modification, storage or copying of
this email or any of its attachments is strictly prohibited.  If you have
received this communication in error, please immediately notify the
[EMAIL PROTECTED] and destroy all copies of this message along with any
attachments.

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to