#!/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