现在的位置: 首页 > 综合 > 正文

expect

2013年01月16日 ⁄ 综合 ⁄ 共 426字 ⁄ 字号 评论关闭
#!/usr/bin/expect -f
set ip [lindex $argv 0]
set dir [lindex $argv 1]
set file [lindex $argv 2]
set timeout 10
spawn ftp $ip
expect "Name*"
send "root\r"
expect "Password*"
send "huawei\r"
expect "ftp>*"
send "lcd $dir\r"
expect {
"*file" {send_user "local $dir no such file or dir";send "quit\r"}
"*now*" {send "put $dir/$file d:/serv_u_root/$file\r"}
}
expect {
"*Failed" {send_user "remote $file no such file";send "quit\r"}
"*OK" {send_user "$file has been uploaded.";send "quit\r"}
}
expect eof

抱歉!评论已关闭.