linux下自动登陆ftp下载文件
时间:2006-12-30 来源:shinewaysoft
操作系统:linux
说明:使用了expect,参数为ftp服务器地址和要下载的文件名
参数:lindex $argv 0 读取ftp服务器ip地址
lindex $argv 1 读取要下载的文件名
编辑:
#vi ftp.sh
spawn ftp [lindex $argv 0]
expect "Name (*):"
send "anonymous\r"
expect "Password:*"
send "\r"
expect "ftp>"
send "binary\r"
expect "ftp>"
send "hash\r"
expect "ftp>"
send "get [lindex $argv 1]\r"
expect "* Transfer complete."
send "exit\r" 执行方法:expect ftp.sh 服务器ip地址 文件名称 (expect ftp.sh 192.168.0.1 filename.txt ) 扩展:可以根据需要把用户名和密码也作为参数输入里边,这个根据个人需求去做
expect "Name (*):"
send "anonymous\r"
expect "Password:*"
send "\r"
expect "ftp>"
send "binary\r"
expect "ftp>"
send "hash\r"
expect "ftp>"
send "get [lindex $argv 1]\r"
expect "* Transfer complete."
send "exit\r" 执行方法:expect ftp.sh 服务器ip地址 文件名称 (expect ftp.sh 192.168.0.1 filename.txt ) 扩展:可以根据需要把用户名和密码也作为参数输入里边,这个根据个人需求去做
相关阅读 更多 +