全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1184|回复: 5
打印 上一主题 下一主题

[疑问] 谁有LINUX 自动传送文件到另一台服务器的脚本?

[复制链接]
跳转到指定楼层
1#
发表于 2016-3-1 15:47:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式


#!/usr/bin/expect -f

\cp -r /usr/local/mysql/data/amh /home/mysql_bak
date=`date +%F`
mv amh $date

tar czf "$date.tgz" "$date"

rm -rf "$date"



然后SCP到另外一台服务器上
2#
发表于 2016-3-1 16:24:09 | 只看该作者
最简单办法
lftp server -u username,password << EOF
mput filename.zip
3#
发表于 2016-3-1 16:47:25 | 只看该作者
主要方法

  1. #!/bin/bash

  2. expect -c "
  3.   spawn scp -r -P 22 -c aes192-cbc [email protected]:/home/oracle/tmp.sql /root/test/
  4.   expect {
  5.     "*assword" {set timeout 300; send "Passwd\r";}
  6.     "yes/no" {send "yes\r"; exp_continue;}
  7.   }
  8.   expect eof"
复制代码


根据需要自己改
6#
发表于 2016-3-1 17:36:03 | 只看该作者
#!/bin/bash

expect -c "
  spawn scp -r -P 22 -c aes192-cbc [email protected]:/home/oracle/tmp.sql /root/test/
  expect {
    \"*assword\" {set timeout 300; send \"Passwd\r\";}
    \"yes/no\" {send \"yes\r\"; exp_continue;}
  }
  expect eof"


或者
rsync
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-1 00:43 , Processed in 0.148494 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表