scp自动拉取数据

前端之家收集整理的这篇文章主要介绍了scp自动拉取数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#!/bin/sh
src_dir=要拉取的目录及文件
dest_dir=拉取到本机的目录
host=机器IP
port=38000 (ssh端口:/etc/ssh/sshd_config)
username=root
password=要拉取机器的机器密码
./expect_scp $host $port $username $password $src_dir $dest_dir
echo "pull data end"
#!/usr/bin/expect
set timeout 3600
set host [lindex $argv 0]
set port [lindex $argv 1]
set username [lindex $argv 2]
set password [lindex $argv 3]
set src_file [lindex $argv 4]
set dest_file [lindex $argv 5]
spawn scp -P $port -r $username@$host:$src_file $dest_file
expect 
{
 "(yes/no)?" 
  {
   send "yes\n"
   expect "*assword:" { send "$password\n"}
  }
  "*assword:" 
  {
   send "$password\n"
  }
}
expect "100%"
expect eof
原文链接:https://www.f2er.com/centos/376813.html

猜你在找的CentOS相关文章