P
PerlNovice
I have the following Perl code:
-------------------------------------------------
#!/usr/bin/perl
use Net::FTP;
$ftp = Net::FTP->new("some.host.name", Debug => 1)
or die "Cannot connect to some.host.name: $@";
$ftp->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
$ftp->cwd("/myfolder")
or die "Cannot change working directory ", $ftp->message;
$ftp->binary;
for( <*.zip> ){
$ftp->get($_,"tmp.$$") or die $!;
$ftp->rename("tmp.$$",$_) or die $!;
$ftp->size($_) == -s $_ or die "$_ sizes don't match";
}
$ftp->quit;
-----------------------------------------------
I need to do the following:
1)I need to copy .zip files from Windows to my Unix folder and name the
..zip files as something else, let's say, .txt. I then need
to rename it back to .zip only when the entire file has been copied.
This is because I'll be unzipping the files later.
There could be multiple .zip files in the Windows folder.
2)Once the file(s) are copied completely, a size comparison needs to be
made between the Windows and Unix sides.
3)If the sizes are the same, then I need to rename the .txt file back
to the .zip file.
I would appreciate any help from anyone.
-------------------------------------------------
#!/usr/bin/perl
use Net::FTP;
$ftp = Net::FTP->new("some.host.name", Debug => 1)
or die "Cannot connect to some.host.name: $@";
$ftp->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
$ftp->cwd("/myfolder")
or die "Cannot change working directory ", $ftp->message;
$ftp->binary;
for( <*.zip> ){
$ftp->get($_,"tmp.$$") or die $!;
$ftp->rename("tmp.$$",$_) or die $!;
$ftp->size($_) == -s $_ or die "$_ sizes don't match";
}
$ftp->quit;
-----------------------------------------------
I need to do the following:
1)I need to copy .zip files from Windows to my Unix folder and name the
..zip files as something else, let's say, .txt. I then need
to rename it back to .zip only when the entire file has been copied.
This is because I'll be unzipping the files later.
There could be multiple .zip files in the Windows folder.
2)Once the file(s) are copied completely, a size comparison needs to be
made between the Windows and Unix sides.
3)If the sizes are the same, then I need to rename the .txt file back
to the .zip file.
I would appreciate any help from anyone.