ftp 自动登录 并回到控制台--interact​的使用
? expect ?    2019-10-23 15:31:52    445    0    0
gua_l   ? expect ?

 

前面在 “expect:scp/ftp 自动化 ”  这一篇中提到:

interact:执行完毕后保持交互状态,并等待手工输入的操作了。

由于ftp 输入密码时敲错时不能使用ctrl+ backspace 进行回退,于是写了一个脚本用于自动操作登录部分,并在脚本执行结束时,将操作交互权交回给控制台,继续手工执行ftp 命令

 

loginftp.sh  ${yuser}  ${ypassword}

#!/usr/bin/expect
set timeout 7200
set FTP "ftp>"
spawn ftp ftp.xxxx.com
 expect {
 "):"
 { send "${yuser}\n"
 expect "*assword:" {send "${ypassword}\n"}
 }
 "*couldn't execute*no such file*"
 {
 print "ftp not install"
 }
}
interact​

 

Pre: Gitlab 的 release 功能

Next: Iptables 学习

445
Sign in to leave a comment.
No Leanote account? Sign up now.
0 comments
Table of content