

_current_timestamp() {
	export TZ=GMT ; date '+%Y%m%dGMT%H%M%S'
}


SITE=$1

type -P lftp &>/dev/null && ISINST=1 || ISINST=0
if [ $ISINST -eq 0 ]
then
	>&2 echo "Error: lftp is not installed"
	exit 127
fi
DT=$(_current_timestamp)
FN="listing"_"$SITE"_"$DT.txt"
if [ ! -f "$FN" ]; then
	if lftp -c "set net:timeout 10; open $SITE && find -l && exit" >"$FN"; then
		#miceweb import "$SITE" "$FN"
		exit 0
	else
		exit 2
	fi
else
	>&2 echo "$FN already exists"
	exit 1
fi
