scp自动写密码脚本-创新互联

scp自动写密码脚本

成都创新互联公司专注于定西企业网站建设,响应式网站,商城网站建设。定西网站建设公司,为定西等地区提供建站服务。全流程按需规划网站,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务
#!/usr/bin/expect
set timeout 10
set host [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set src_file [lindex $argv 3]
set dest_file [lindex $argv 4]
spawn scp $src_file $username@$host:$dest_file
 expect {
 "(yes/no)?"
  {
  send "yes\n"
  expect "*assword:" { send "$password\n"}
 }
 "*assword:"
{
 send "$password\n"
}
}
expect "100%"
expect eof

使用格式:

./scp.sh  [目标IP地址] [用户名] [密码] [文件名]  [目标位置]

./scp.sh  172.168.24.1 root awcloud demo.tar.gz  /root/


本文名称:scp自动写密码脚本-创新互联
当前路径:http://myzitong.com/article/jigds.html