#!/usr/gnu/bash

# Written by Joseph Clancy (jclancy@wimsey.com).
# Copyright (c) 1996, and placed under the GPL; see COPYING for further info.

# snagit <url> <realname> <id> <args>

count=0
if [ ! -f $2.real ]; then
  while [ $count -lt 5 ]; do
    count=$[$count+1]
    lynx -source "$1" > $2.real
    if [ -z `lynxerror $2.real` ]; then
      cat $2.real | chaserefs "$1" $3 $4 $5 $6 > $2
      break;
    else
      echo -n "(retrying) "
      rm $2.real
    fi
  done
  if [ $count = "5" ]; then
    echo "(error) $2"
    echo $1 $2 >> $3.error
  fi
fi
