This simple example illustrates logging in to a host using anonymous FTP and then passing control back to the user:
set host localhost set name myname@myhost spawn ftp $host expect "Name (*):" send "anonymous " expect "Password:" send "$name " expect { "ftp>" { interact } "Login failed." { exit 1 } timeout { exit 1 } }