By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,178 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,178 IT Pros & Developers. It's quick & easy.

HOw will I display the missing file together the date when it was not created?

P: 2
Hello. Below is a perl script wherein it has to display date when was the last update/change on the directory.

Expand|Select|Wrap|Line Numbers
  2. #!/usr/bin/perl
  3. use File::stat;
  4. use Time::localtime;
  6. my @a = glob "*" ;
  7. foreach (@a) {
  9.     if ( -e $_)
  10.     {
  11.         my $d = ctime(stat($_)->mtime);
  12.         print "FILE:  $_  \n DATE UPDATED:  $d.\n";
  13.     }
  14.     else
  15.     {
  16.             print "No file found $_.\n";
  17.     }
  18. }
It display like this:

Expand|Select|Wrap|Line Numbers
  1. Code:
  3. FILE:  mrm
  4.  DATE UPDATED:  Fri Jul 23 21:35:03 2010.
  5. FILE:  mysql
  6.  DATE UPDATED:  Fri Jul 23 21:37:08 2010.
On the display, MRM and MYSQL our directories and it displays the date when it was last updated. Each directory have a file like this: mysql07232010-18:00.gz for mysql directory and mrm07232010-18:00.gz for MRM directory (the backup file). Every day it creates new file with almost the same file name, the only difference is that the number changes because it depends on the date when it was created.

My problem is how will I add on the script above where it will display the file and date when it has no backup.

Sample Output: (let say the directory does not update for two days (Jul 22 and 23).

Expand|Select|Wrap|Line Numbers
  1. FILE:  mysql
  2.   REMARKS:  No Backup on Thu Jul 22 2010.
  3.             No Backup on Fri Jul 23 2010.
Your help is very much appreciated. Thank you so much.
Jul 26 '10 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 983
Not to sound trite, but you have to design your algorithm and implement it..

Start by thinking about your requirements.

Determine how to extract the date from the existing files' names.

Then ask how you know which dates are missing.

Finally, write the result.
Jul 26 '10 #2

P: 2
thanks sir
Jul 27 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.