; Autoftp : A script to automatically ftp files from an Aminet archive site.
;
; Autoftp uses ncftp and AmiTCP to function, if you don't have both of these
; working, Autoftp won't be useful to you.
;
; Keywords accepted :  YES -- Download a new RECENT file, without asking user
;                       NO -- Don't download the new RECENT file
;              (otherwise) -- Display a requester asking whether to download
;                             the new RECENT file or not.
; 
; THINGS TO CHANGE FOR YOUR SETUP
;
; 1) Make sure the EasyReq and UniqueFile commands are in your search 
;    path... c: is a good place for them.
; 2) Make sure GadMget is in your search path, or specify it's location
;    on the line where it is called, below
; 3) If you want to use a site other than wcarchive.cdrom.com, search
;    and replace with your preferred site
; 4) Autoftp is currently configured to store the RECENT file in txt:, and
;    the downloads in dn:.  Assign these directories to where you want
;    the files kept, or change the references in the script.
;
.bra {
.ket }
.key GETRECENT
failat 25

stack 50000		;ncftp can abort if it doesn't have plenty of stack!

if {GETRECENT} EQ "YES"
	echo "1" > env:GadAnswer
else
	if {GETRECENT} EQ "NO"
		echo "2" >env:GadAnswer
	else
		easyreq >env:GadAnswer "Do you want to download a new RECENT listing?" "GadMGet Script" "Yes|No|Cancel"
	endif
endif

if $GadAnswer eq 0
	endcli
	quit
endif

if $GadAnswer eq 1
  cd txt:			;Change this to wherever you wish to keep RECENT
  amitcp:bin/ncftp -r wcarchive.cdrom.com:/pub/aminet/RECENT	;Change this to your favorite FTP site
endif

uniquefile t:AutoFTP.GetList >env:GETLISTFILE

;You may need to specify the path to GadMGet here if it's not in your default path!
gadmget txt:recent OUTPUT $GETLISTFILE NOSIMPLEPATHS KEEPGETSORT GETSORT Size

if not `list $GETLISTFILE lformat="%L"` eq "empty"
	cd dn:		;Change this to wherever you want to receive your new files
	amitcp:bin/ncftp -r wcarchive.cdrom.com:/pub/aminet/ <$GETLISTFILE	;Change this site as well
endif

delete env:GETLISTFILE QUIET

endcli
