#!/usr/bin/perl

  use DBI;
  use Time::Local;

  use FindBin qw ($Bin);
  use lib "$Bin/cal_pipe2";
  use cal_pipe2;

  # Command line argument contains name of commands file.
  # Die of no arguments.
  if ($#ARGV ne 0) {
    print "vims_cal_pipe takes one command line argument:\n";
    print "   the name of commands file\n";
    die;
  }

  open (CFILE, $ARGV[0]) or die "Can't open ",$ARGV[0],": $!\n";

  # Read command file, this contains keyword=value pairs, keywords are:
  # files, descend, mark_saturated, flat_field,
  # perf_function, sol_spect_deconvol, geom_correct

  my %cmds = ();
  while ($line = <CFILE>) {
    ($key, $val) = $line =~ /\s*(\w+)\s*=\s*([\w-:\.]+)/;
    $cmds{$key} = $val;
  }

  close CFILE;  

  $thedir  = $cmds{"files"};
  $descend  = $cmds{"descend"};

  print "thedir = $thedir\n";
  print "descend = $descend\n";

  # Call the main routine.
  cal_pipe2 ($thedir, $descend, %cmds);
