hi all
I am doing a task to ftp to a server and pick up a file which is one day older than the current date
I am using the perl Net:FTP module

files are in the format yearmonthday.dat e.g. 20030601.dat (Ist of june)
my @current = `date`; ($dnr,$month,$date,$tnr,$rr,$year)= split(/\s+/,$current[0]); chomp $year;chomp $date;chomp $month; $date-=1; my %month_conv=("Jan"=>"01","Feb"=>"02","Mar"=>"03","Apr"=>"04","May"= +>"05","Jun"=>"06","Jul"=>"07","Aug" =>"08","Sep"=>"09","Oct"=>"10","Nov"=>"11","Dec"=>"12",); $pingmonth=$month_conv{$month}; $filename="$year$pingmonth$date.dat"; print "getting $filename\n"; $dir='/log_recv/telecom/DATA'; use Net::FTP; $ftp = Net::FTP->new("aaa.com")|| die("Could not connect: $@\n +"); $ftp->login("xxx","yyy")||die("Wrong username or password "); $ftp->binary(); $ftp->cwd("$dir")||die("Could not change path "); #@aa=$ftp->ls("$dir"); $ftp->get("$filename")|| die("File not found $filename\n"); $ftp->quit;

i would like to know the best method for handling end of the month conditions. e.g. on the 1st of june my script would fail
I had thought of
run ls -t take the output in an array and pick up arr1(second field as we need a one day older file)<how is this done using Net:FTP
convert to epoch seconds minus 86400 convert back and get .
anyideas on a efficient and reliable way
thanks

In reply to FTP and get file date manipulation problem by chimni

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.