Shell/perl script to check for files

Hi,

I am trying to write a script for following scenario:

I have a list of countries from where I receive files...eg. (Indonesia, Thailand, Australia...etc)

For each country, I have a list of files that they send.

IND -- a,b,c
TH -- p,q,r
AU -- x,y,z
The path for these files could be common, or exclusive to a particular country.

For each country, I also have a list of holidays. eg.

IND - Jan 1 , May 1
TH - Jun 20, May 1
AU - Dec 25 , Oct 21..

For these holidays, I also have an exclusion list.

So, even if it's a holiday, say for TH, we would still get files p & r (not q) - and this rule is valid for all holidays in TH. Similarly for other countries.

I need to do the following:

  1. Loop through the countries
  2. For each country check if current day is a holiday
  3. If not a holiday, check if file exists
  4. If it's a holiday for a particular country, check the exclusion list, and determine if the holiday files have arrived.
  5. Have a detailed output such as:

    Country Filename Date Comments
    TH p 6/20 Received
    TH q 6/20 not expected, as Holiday
    TH r 6/20 expected - but not received !

Challenges that I am facing:

  • How do I maintain the static data?
  • For list of countries I can have a txt file
  • For Holidays, should I have a csv file
  • Can I include, all info in a csv file? If yes, how should it be structured?

Would appreciate if people can share best practices, or give me some pseudo code/ code or pointers...Any help is much appreciated.

This needs to be a .ksh or a maybe a perl script. I am thinking perl, because I may be able to organise the data as an array.

Thanks!

Is this homework? What have you tried so far?

You can have one csv file with below format

COUNTRY, FILES, HOLIDAYS, FILES DURING HOLIDAYS