#!/usr/bin/expect -f
#=============================================================
# ftp.exp #
# written by dongxiaobing #
# 版本:V1 #
# 文件下载 #
# #
# #
# #
# #
#=============================================================#
set ip [lindex $argv 0 ]
set dir1 [lindex $argv 1 ]
set dir2 [lindex $argv 2 ]
set file [lindex $argv 3 ]
set timeout 10
spawn ftp $ip
expect "Name*"
send "idnms\r"
expect "Password:*"
send "kindsoft\r"
expect "ftp>*"
send "cd $dir1\r"
expect {
"*Failed" { send_user "550 Failed to change directory\r";send "quit\r" }
"*successfully" { send "get $dir1/$file $dir2/$file\r"}
}
expect {
"*Failed" { send_user "550 Failed to open file\r";send "quit\r"}
"*OK" { send_user "$file has been download\r";send "quit\r"}
}
expect eof
#=============================================================
# ftp.exp #
# written by dongxiaobing #
# 版本:V1 #
# 文件下载 #
# #
# #
# #
# #
#=============================================================#
set ip [lindex $argv 0 ]
set dir1 [lindex $argv 1 ]
set dir2 [lindex $argv 2 ]
set file [lindex $argv 3 ]
set timeout 10
spawn ftp $ip
expect "Name*"
send "idnms\r"
expect "Password:*"
send "kindsoft\r"
expect "ftp>*"
send "cd $dir1\r"
expect {
"*Failed" { send_user "550 Failed to change directory\r";send "quit\r" }
"*successfully" { send "get $dir1/$file $dir2/$file\r"}
}
expect {
"*Failed" { send_user "550 Failed to open file\r";send "quit\r"}
"*OK" { send_user "$file has been download\r";send "quit\r"}
}
expect eof
自动化FTP文件下载脚本
本文介绍了一个使用Expect语言编写的自动化FTP文件下载脚本。该脚本可以根据提供的参数连接到指定的FTP服务器,并从服务器上下载指定目录下的文件到本地特定路径。此脚本适用于需要定期从远程FTP服务器获取文件的场景。
514

被折叠的 条评论
为什么被折叠?



