#!/bin/bash
/usr/bin/expect -c '
# 向远程服务器请求打开一个FTP会话,并等待服务器询问用户名
spawn ftp $remote_server expect "username:" # 输入用户名,并等待服务器询问密码 send "$my_user_id\r" expect "password:" # 输入密码,并等待FTP提示符的出现 send "$my_password\r" expect "ftp>" # 切换到二进制模式,并等待FTP提示符的出现 send "bin\r" expect "ftp>" # 关闭ftp的提示符 send "prompt\r" expect "ftp>" # 下载所有文件 send "mget *\r" expect "ftp>" # 退出此次ftp会话,并等待服务器的退出提示EOF send "bye\r" expect eof '