#! /bin/sh
# This is the LHEA perl script: /data/irby/heasoft-6.10/heasoft-6.10/ftools/i386-apple-darwin9.8.0/bin/st.pl
# The purpose of this special block is to make this script work with
# the user's local perl, regardless of where that perl is installed.
# The variable LHEAPERL is set by the initialization script to
# point to the local perl installation.
#-------------------------------------------------------------------------------
eval '
if [ "x$LHEAPERL" = x ]; then
  echo "Please run standard LHEA initialization before attempting to run /data/irby/heasoft-6.10/heasoft-6.10/ftools/i386-apple-darwin9.8.0/bin/st.pl."
  exit 3
elif [ "$LHEAPERL" = noperl ]; then
  echo "During LHEA initialization, no acceptable version of Perl was found."
  echo "Cannot execute script /data/irby/heasoft-6.10/heasoft-6.10/ftools/i386-apple-darwin9.8.0/bin/st.pl."
  exit 3
elif [ `$LHEAPERL -v < /dev/null 2> /dev/null | grep -ic "perl"` -eq 0 ]; then
  echo "LHEAPERL variable does not point to a usable perl."
  exit 3
else
  # Force Perl into 32-bit mode (to match the binaries) if necessary:
  if [ "x$HD_BUILD_ARCH_32_BIT" = xyes ]; then
    if [ `$LHEAPERL -V 2> /dev/null | grep -ic "USE_64_BIT"` -ne 0 ]; then
      VERSIONER_PERL_PREFER_32_BIT=yes
      export VERSIONER_PERL_PREFER_32_BIT
    fi
  fi
  exec $LHEAPERL -x $0 ${1+"$@"}
fi
'
if(0);
# Do not delete anything above this comment from an installed LHEA script!
#-------------------------------------------------------------------------------
#!/usr1/local/bin/perl

$ra = $ARGV[0];
$dec = $ARGV[1];
$equi = $ARGV[2];
$fits = $ARGV[3];
$radius = $ARGV[4];
$name=$ARGV[5];

if( $name eq '' ||
    $ra eq '' ||
    $dec eq '' ||
    $equi eq '' ||
    $radius eq '' ||
    $fits eq '') {

    die "
 
Usage st.pl     ra       dec   equinox    file format   image side  survey
          (degrees real )   B(J)year  fits or gif  (arcmin) (1 1st 2 2nd 3 2nd or 1st if 2nd not available)
        (hh:mm:ss. dd:mm:ss. )   

 e.g.  st.pl 180.000 30.000 B1950 f 5.0 3

\n";
}


$cmd= "xwebquery.pl host='stdatu.stsci.edu' url='/cgi-bin/dss_search' " .
       "method=GET ".
       "v='$name' ".
       "r='$ra' d='$dec' " .
       "e='$equi' " .
       "f='$fits' h='$radius' w='$radius' " .
       "c=none" ;

print STDERR "$cmd\n";

@out= `$cmd`;

for ($i=0; $i <= $#out; $i += 1) 
    {
	print $out[$i];
}
