简介:
实现上述功能使用了两个脚本:总的调用脚本和sftp脚本
sftp.sh脚本
内容见下文,功能是sftp输入密码后上传指定的文件,脚本运行时需要带上传文件名参数,例如要上传a.txt ,就执行sftp.sh a.txt.
#!/usr/bin/expect
set timeout 10
# get file name from input
set file [lindex $argv 0]
# login
spawn sftp ems@192.168.1.1
expect "password:"
#input password
send