#!/usr/bin/perl
#
# Copy a fresh set of raw images from the June 21, 2014, directory.
#
# MWR 3/24/2022

$debug = 1;

$in_dir = "/home/richmond/z1/ritobs/jun21_2014";
$out_dir = ".";

# copy 1-second dark frames
for ($i = 1; $i <= 10; $i++) {
  $infile = sprintf "%s/dark1-%03d.fit", $in_dir, $i;
  $outfile = sprintf "%s/dark1-%03d.fit", $out_dir, $i;
  $cmd = "cp $infile $outfile";
  $ret = exec_cmd($cmd);
}

# copy 30-second dark frames
for ($i = 1; $i <= 10; $i++) {
  $infile = sprintf "%s/dark30-%03d.fit", $in_dir, $i;
  $outfile = sprintf "%s/dark30-%03d.fit", $out_dir, $i;
  $cmd = "cp $infile $outfile";
  $ret = exec_cmd($cmd);
}

# copy flatclear images
for ($i = 1; $i <= 10; $i++) {
  $infile = sprintf "%s/flatclear-%03d.fit", $in_dir, $i;
  $outfile = sprintf "%s/flatclear-%03d.fit", $out_dir, $i;
  $cmd = "cp $infile $outfile";
  $ret = exec_cmd($cmd);
}

# copy target images 50-59
for ($i = 50; $i <= 59; $i++) {
  $infile = sprintf "%s/asas14clclear-%03d.fit", $in_dir, $i;
  $outfile = sprintf "%s/asas14clclear-%03d.fit", $out_dir, $i;
  $cmd = "cp $infile $outfile";
  $ret = exec_cmd($cmd);
}





exit 0;



##############################################################################
# PROCEDURE: exec_cmd
#
# DESCRIPTION: Execute the given shell command line.  If the $debug flag
#              is set, we print to stdout the command line, and
#              also print out the result string.
#
# RETURNS:
#              the result of the command
#
#
sub exec_cmd {

  my($cmd, $ret);

  $cmd = $_[0];

  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;
  if ($debug > 0) {
    printf "ret is ..$ret.. \n";
  }

  return($ret);
}


