#!/usr/bin/ksh
#
# sequence_summary_2_html: this script reads in files containing summaries of 
# ASCA processing sequences (as produced by sequence_summary.ksh) and creates 
# a new html file from them. If the input file 
# has the name of *.summary then the output file has the name *.html. The only 
# command line argument ($1) is the directory where the sequence summary files 
# may be found.
# 
cd $1
IFS="
"
for j in *.summary
do
  file=$(echo $j | awk '{print substr($0,1,length($0)-8)}')
  print "< title > ASCA Sequence $file < /title >"  > $file.html
  print '< H3 > Click on sequence number to see a complete processing log for        that sequence < /H3 >'  > > $file.html
  print '< HR >'  > > $file.html
  for i in $(cat $j)
  do 
    echo $i | awk 'BEGIN{FS = "|"}
    {
    printf("< H2 > Sequence < A HREF=\"/cgi-bin/createpage.sh?%s\" > %s < /A >< /H2 >      \n",$1,$1);
    printf("< OL > \n");
    printf("< LI > Object name:                                %s \n",$10);
    printf("< LI > RA/DEC (decimal degrees):                   %s/%s \n",$2,$3);
    printf("< LI > Roll Angle:                                 %s \n",$4);
    printf("< LI > NRA Number:                                 %s \n",$7);
    printf("< LI > Observation Start Time (dd/mm/yy,hh:mm:ss): %s,%s \n",            substr($5,1,8),substr($5,10,8))
    printf("< LI > Observation End Time (dd/mm/yy,hh:mm:ss):   %s,%s \n",            substr($6,1,8),substr($6,10,8))
    printf("< LI > Processing Date (dd/mm/yy):                 %s/%s/%s \n",         substr($8,5,2),substr($8,3,2),substr($8,1,2));
    printf("< LI > Data Public Release Date (dd/mm/yy):        %s \n",$9);
    printf("< /OL > \n");
    printf("< HR > \n");
    }'  > > $file.html
  done
done
exit 0