记住这个例子,以后就知道怎么用了
#!/usr/bin/expect -f
set ipaddress [lindex $argv 0] //第一个参数,下面类推
set username [lindex $argv 1]
set password [lindex $argv 2]
spawn ftp $ipaddress //程序开始spawn 是标志,后面是要执行的命令
expect "*Name*" //匹配字符
send "$username\n" //发送参数,
expect "*Password:*"
send "$password\n"
expect "*ok*ftp>*"
send "get test\n" //执行操作
expect "*ftp>*"
send "quit\n"
expect eof //OVER
阅读(1110) | 评论(0) | 转发(0) |