Hi Monks, I have a FTP script that does the ftp from the server. The server conatin plenty of zip files, in those files i require few ie latest ones, and for the single day there will be multiple files in this format
arident16_Jul282009_2358.zip arident16_Jul282009_2320.zip arident16_Jul272009_1619.zip
I want o campare if it is todays files and time is 2358 then only it should be allowed to be ftp'ed else let it be in the server. I am pasting my code here....
#!/usr/bin/perl use Net::FTP; use Archive::Zip; use IO::File ; print "Retrieving file from abc.com...\n"; $loginip='12.34.56.78'; $loginid='login'; $loginpaswd='password'; ($sec,$min,$hour,$mday,$mon,$year)=(localtime(time))[0,1,2,3,4,5]; $time_stamp= "_" . (1900+$year) . "_" . ($mon+1) . "_" . ($mday) . "_" + . $hour . "_" . $min . "_". $sec; printf "time stamp = $time_stamp\n"; unless(-d "TFLogs") { mkdir("TFLogs"); } if( -d "TFLogs") { chdir("TFLogs"); } $ftp = Net::FTP->new(($loginip), Debug => 0) or die "Cannot connect to abc.com: $@ \n"; $ftp->login($loginid,$loginpaswd) or die "Cannot login ", $ftp->message; $source_dir="nt12/logs/"; $ftp->cwd($source_dir) or die "Cannot change working directory ", $ftp->message; $ftp->binary || die "Unable to set mode to binary. ", $ftp->message; @list=$ftp->ls(); printf "list = \n"; print @list; foreach $file (@list) { <quote> i want to fit in my code here to check for the latest file and time. </quote> $ftp->get($file) or die "get failed ", $ftp->message; my $zipname = $file; my $destinationDirectory = 'C:\Perl Script\TFLogs'; my $zip = Archive::Zip->new($zipname); foreach my $member ($zip->members) { next if $member->isDirectory; (my $extractName = $member->fileName) =~ s{.*/}{}; $member->extractToFileNamed( "$destinationDirectory/$extractName"); } } $ftp->quit;
Thanks NT

In reply to date in required format by namishtiwari

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.