#!/bin/bash
#
# Make sure that this program can delete it's temporary files.
  umask o+rwx
#
# If the mission had waypoints, gobble up syslog and extract 
# waypoint information.
#
  if [ -s syslog ]
  then
    grep wplog syslog > temp.txt
  else
    echo "Syslog is empty."
  exit -1
  fi

  if [ -s temp.txt ]
  then
    echo "Extracting waypoints from syslog."
  else
    exit -1
  fi
  #
  # This gnarly sed command inserts a ' at the start and end of each line.
  #
  cat temp.txt | sed 's/^/'\''/' | sed 's/$/'\''/' > temp1.txt

  echo "dataWPstr = [ ... " > waypoint.m
  cat temp1.txt >> waypoint.m
  echo " ];" >>    waypoint.m

  rm temp.txt
  rm temp1.txt
