#!/bin/sh
# $Id: aftp,v 1.6 1999/08/08 02:56:00 dunc Exp $
# the next line is obeyed by sh but not expect \
exec expect -f "$0" -- "$@"
puts "\$argv is $argv"
spawn ftp $argv
set timeout 60
expect \
{
  timeout {puts "timed out";exit}
  -nocase "unknown host" exit
  -nocase "connection refused" exit
  "Name"
} ;# expect
set timeout 20
exp_send anonymous\r
expect \
{
  "Service not available" exit
  "Password:" {}
} ;# expect
exp_send dunc@apex.net.au\r
interact
