bash 将文件从服务器 A 复制到服务器 B 的 shell 脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20826588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 09:06:33 来源:igfitidea点击:
shell script to copy files from Server A to Server B
提问by temp
I am writing a shell script to copy different extension files from server A to server B but it is not working. I have used this but not working.
我正在编写一个 shell 脚本来将不同的扩展文件从服务器 A 复制到服务器 B,但它不起作用。我用过这个但没有用。
#!/bin/sh
echo "copying from Log Folder"
cd /hosting/a/apache-tomcat-7.0.39/logs
echo "Started the transferring files from PROD to FTP server"
echo "transferring Started"
HOST=Xyz.a.com
USER=log
PASS=log
ftp -n $HOST << EOF
echo "connection success"
user $USER $PASS
echo "login success"
put File1_log.txt
echo "transferred success"
echo "renamed success"
if [ $? -eq 0 ]
then
echo "Success.log">>success.log
else
echo "Error.log">>Error.log
bye
EOF
This part is not working properly.
这部分工作不正常。
回答by Barmar
Assuming you have SSH access to the server, use rsync:
假设您可以通过 SSH 访问服务器,请使用rsync:
rsync File1_log.txt $HOST:

