#!/usr/bin/perl
#
#

$debug = 1;

# find the sky value
$cmd = "sky m51.fit";
$ret = exec_cmd($cmd);

# run stars
$cmd  = "stars m51.fit ";
$cmd .= "  minsig=5 minfwhm=1.8 maxfwhm=4.2 ";
$cmd .= "  minround=-1.0  maxround=1.0 ";
$cmd .= "  minsharp=0.3   maxsharp=0.9 ";
$cmd .= "  movemax=2.0 ";
#$cmd .= "  verbose show ";
$cmd .= "  outfile=m51.coo ";
$ret = exec_cmd($cmd);

# measure instrumental magnitudes for the stars
$cmd  = "phot m51.fit infile=m51.coo outfile=m51.pht ";
$cmd .= "  skyinner=10 skyouter=20 ";
$cmd .= "  aper=4 ";
$cmd .= "  empscatter ";
#$cmd .= "  verbose show ";
$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);
}


