Chinaunix
标题:
linux下自动登陆ftp下载文件
[打印本页]
作者:
shinewaysoft
时间:
2006-12-30 13:21
标题:
linux下自动登陆ftp下载文件
操作系统: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 )
扩展:可以根据需要把用户名和密码也作为参数输入里边,这个根据个人需求去做
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u/29219/showart_223615.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2