How to download a Topcon GB-1000 receiver using lftp
How to download a Topcon GB-1000 receiver using lftp
Use the following script utilizing lftp to download data off the internal memory of a Topcon GB-1000 receiver. This script uses lftp’s ability to mirror two directories.
# Script to mirror the internal memory# of a Topcon GB-1000 to a local directory.
# File download is quite fast: takes about 82seconds
# for a daily 1second file.
#
# Setup:
# Set your ethernet port on your computer to have IP: 192.168.1.3
# and Subnet-Mask: 255.255.255.0. Then connect an ethernet
# cable from your computer to the GB-1000.
#
# Use:
# user@linux> ./ftp_download <dir-to-downlaod-to>
#
# Example:
# user@linux> ./ftp_downlaod site1
# ( will download data to ./site1/ )
#
# If the local directory does not exist lftp will
# create.
#
# Behavior of script if you run it more than once
# against the same local direcotry:
#
# 1) matching files are skipped and nothing is done.
# 2) if a new file is on the GB-1000 that is not on the
# local directory it is copied over.
# 3) if there is a difference between a file on the GB-1000
# and on the local direcotry (possibly because you have
# previously downloaded a partial file and now the file is
# bigger) the script will delete the smaller local file and
# replace it with the new larger file.
#
# Note: If you kill the script while it is running with ctrl-c
# make sure to run:
#
# user@linux> rm -f lftp_download_cmds.x
#
# to clear the file containing lftp commands generated by the
# script. The file is deleted after a successful execuation
# of the script.
#! /bin/bash
# Constants needed.
HOST=’192.168.1.2’ # IP of GB-1000
SITE=$1 # dwnld dir specifed at run time
USER=’’ # user name
PASSWD=’TOPCON’ # GB-1000 password
CMD_FILE="./lftp_download_cmds.x" # file contaning lftp commands
# Can’t run if you don’t specify a directory to download to.
if [ "$SITE" = "" ]; then
echo "You must specify a download directory. "
exit 1
else
# Commands to be fed into lftp.
echo "open -u $USER,$PASSWD $HOST" >> $CMD_FILE;
echo "mirror -e --verbose=3 / test/" >> $CMD_FILE;
# Run lftp with the command file created above.
lftp -f $CMD_FILE
# Clean up, delete lftp_download_cmds.x file.
rm -f $CMD_FILE
fi