#!/bin/sh

# Pick up a file hands-free: batchftp sitname directory file

case $# in
	3);;
	*) echo "Usage: $0 site dir file" >&2
	   exit 1;;
esac

site=$1
dir=$2
file=$3

expect <<!
set timeout 60
spawn ftp gw
expect -re ".*Name .*:"
	send anonymous@$site\n
expect -re ".*Password:"
	send user@domain.com\n
expect -re ".*ftp> "
	send cd $dir\n
expect -re ".*ftp> "
	send binary\n
expect -re ".*ftp> "
    set timeout 100000
	send get $file\n
expect -re ".*ftp> "
	send quit\n
!
ls -l $file



