Automating your FTP session using expect
Shamelessly derived from a code on the Wikipedia entry for Expect, here is how you would automate a FTP session:
# Open an ftp session to a remote server, logs in using your credentials and retrieves the current
# directory listing from there
# Amit k. Saha
# This is how you set variables in 'expect'
set remote_server your-ftp-server
set my_user_id your-user-ide
set my_password your-pass
spawn ftp $remote_server
# Send the username, and then wait for a password prompt.
# Send the password, and then wait for an ftp prompt.
# list all the files
send "ls \r"
# Exit the ftp session, and wait for a special end-of-file character.