#!/usr/bin/perl
#
sub htencode {
    local($htencd) = shift;
    $htencd =~ s/&/&amp;/g;
    $htencd =~ s/"/&quot;/g;
    $htencd =~ s/</&lt;/g;
    $htencd =~ s/>/&gt;/g;
    $htencd;
}
  do "acqPATHs.pl";
  $wdr = $ENV{"QUERY_STRING"};
  print "Content-type: text/html; charset=iso-8859-1\n\n";
#
  $htmlbody =<<EOM;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link rel="stylesheet" type="text/css" href="/AMXS/amxs.css">
<title>AMXS files</title>
<script type="text/javascript">
<!--
function RmCWD() {
  location.replace("/cgi/AMXS/rmcwd.cgi?__WDR__");
}
function cancel() {
  location.replace("/AMXS/forms/blank.html");
}
//-->
</script>
</head>
<body bgcolor="ivory" style="margin: 4px 7px;">
<form name="FM">
<hr>
<i>Existing files</i> : &nbsp; &nbsp; &nbsp;
 <input type="button" value="OK" onclick="cancel()">
EOM
  $htmlbody =~ s/__WDR__/$wdr/g;
  print $htmlbody;
#
  $n = 0;
  open(IN, "ls -lF $DATAPATH/$wdr 2>&1 |");
  print "<pre>";
  while ($line=<IN>) { print &htencode($line); $n++; }
  print "</pre>\n";
  close(IN);
  if ($n < 2) {
    print " &nbsp; &nbsp; ";
    print '<input type="button" value="rmCWD" onclick="RmCWD()">', "\n";
    print "(Remove current working directory)\n";
  }
#
  print "</form>\n</body>\n</html>\n";
  exit(0);
