expect结合scp实现文件上传

来源:互联网 发布:车载数据采集系统 编辑:程序博客网 时间:2024/06/05 04:20
#!/usr/bin/expectset timeout 100set host [lindex $argv 0]set username [lindex $argv 1]set password [lindex $argv 2]spawn scp -r  file $username@$host:/路径/file expect { "(yes/no)?"  {  send "yes\n"  expect "*assword:" { send "$password\n"} } "*assword:"{ send "$password\n"}}expect "100%"expect eof

调用格式

expect ./scp.exp  参数1  参数2 参数3    expect ./scp/exp user 666666 192.169.1.100

网上有很多教程,不在赘述,需要注意的地方 { 前后必须要有空格!

0 0
原创粉丝点击