#!/bin/sh
# hhg - use hhcp to get directory listings and files via FT-RELAY from
#       specific sites (unix and simtel20) offering public access
#
# Version 1.0
#   H.Boothroyd, Warwick Business School, October 1991
#   bsrdp@warwick.ac.uk
# Reworked from FTGET Version 1.0 for FT-RELAY calls to unix sites by
#   Nino Margetic, Dept. of Medical Physisc, UCL
#   nino@mph.sm.ucl.ac.uk
# Tested only under  csh  under  SunOS 4.1.1
#
# Before first use, record some permanent data using the following two
# commands and using your email address in place of mine:
#        hhalias  UK.AC.FT-RELAY  ftb
#        hhstore  ftb
#               transfer authorization: anonymous
#               transfer password: bsrdp@warwick.ac.uk
#               binary word size: 8
#            (press ENTER to skip each other line offered by hhstore)
#
# If an  hhg  request
#    *  works, a suitably named file will arrive,
#    *  fails, you will get an automatic mail report,
#    *  seems to have got lost, you can look for information about it
#       using a command of the form
#               hhq -u bsrdp
#       and you can look for fuller details of attempts using
#               hhlog | less

site=$1
case $2 in
"") echo "My use:  hhg site directoryname [-b] filename"
    echo "         hhg site directoryname "
    echo "             |"
    echo "             simtel20  pd1:<msdos.d>f"
    echo "             wuarchive /mirrors/msdos/d/f"
    echo "             garbo     /pc/d/f"
    echo "             garbou    /unix/d/f"
    echo "             nic       /pub/msdos/d/f"
    echo "Example: hhg wuarchive arc-lbr -b fv138.zip"
    echo "Example: hhg wuarchive ."
    exit 1  ;;
 *) shift ;;
esac

# unix separators
ds="/" ; dz="" ; df="/" ;
# site details
case $site in
simtel20)  host="wsmr-simtel20.army.mil" ; bdir="pd1:<msdos" ;
# tops20 separators
             ds="." ; dz=">" ; df="" ;;
wuarchive) host="wuarchive.wustl.edu" ; bdir="/mirrors/msdos" ;;
garbo)     host="garbo.uwasa.fi" ; bdir="/pc" ;;
garbou)    host="garbo.uwasa.fi" ; bdir="/unix" ;;
nic)       host="nic.funet.fi" ; bdir="/pub/msdos" ;;
*)         echo "Site $site not included" ; exit 1 ;;
esac

case $1 in
.) dir=$bdir$dz      ; locdir=$site     ;;
*) dir=$bdir$ds$1$dz ; locdir=$site.$1  ;;
esac

case $2 in
 -b) swch=$2 ; shift ;;
  *) swch=  ;;
esac

case $2 in
"") hhcp -L ftb:"$host::(D)$dir"          $locdir.dir ;;
 *) hhcp -L $swch ftb:"$host::$dir$df$2"  $locdir.$2  ;;
esac
exit 0
#end of hhg
