Sunday, August 8, 2010

Include FTP commands in Shell Scripts.

The first part of getting a working cron updater for GIS data is downloading the neccessary data in a form that can be executed from a linux shell (I'm using cron). So, retrieving the file will require using FTP to go out and get the file from a foreign server. Here is the text of the shell script that I use to do this - just executing this script goes out, retrieves the file and places it in a known directory so that I can work with it.

Here was my working script (ftp.sh):

#!/bin/bash
HOST='kcwppub3.co.kitsap.wa.us' # change the ipaddress accordingly
USER='anonymous' # username also change
PASSWD='email_address' # password also change
ftp -n $HOST <quote USER $USER
quote PASS $PASSWD
bin
prompt off
cd /gis/datacd/arcview/layers/parcel/ # this folder contains files...
lcd /home/dom/Downloads/ # this location is local directory
mget parcels.zip
bye
END_SCRIPT

INformation adapted from this source.

No comments:

Post a Comment