简体   繁体   English

linux或Windows shell脚本上传文件并将其复制到另一台服务器

[英]linux or windows shell script to upload a file and copy it to another server

I am struggling with a problem. 我正在为一个问题而苦苦挣扎。 I have: 我有:

  • ServerA (is closer to me and much faster) ServerA(离我更近并且更快)

  • ServerB (is my website where I want the final file to stay) so what I want to do with the shell script (either Windows batch or linux, I have cygwin installed) is, passing the filename as parameter: ServerB(我希望保留最终文件的网站是我的网站),因此我要使用外壳程序脚本(无论是Windows批处理还是linux,我都安装了cygwin),将文件名作为参数传递:

1) upload with FTP a file to ServerA 1)使用FTP将文件上传到ServerA

2) login with ssh on serverB and wget the file from serverA 2)在serverB上使用ssh登录并从serverA中获取文件

I managed to do 1 with a shell script, but I don't understand how to do step2 in the shell? 我设法用shell脚本执行了1,但是我不明白如何在shell中执行step2?

Thanks 谢谢

I would recommend using scp to accomplish step 2. You can use the syntax: 我建议使用scp完成步骤2。您可以使用以下语法:

scp path/to/file serverb@hostname:/path/to/destination . scp path/to/file serverb@hostname:/path/to/destination

You can read more about the syntax for scp here: http://www.hypexr.org/linux_scp_help.php 您可以在此处阅读有关scp语法的更多信息: http : //www.hypexr.org/linux_scp_help.php

您可以使用TeraTerm,它具有强大的脚本语言来自动化两个任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Linux Shell脚本复制目录中文件的最后几行以追加到另一个目录中的文件 - Linux shell script to copy last lines of a file in a directory to append to a file in another directory 将Windows bat文件转换为linux shell脚本 - Translating windows bat file to linux shell script 如何使用Linux Shell脚本读取文本文件列并将文件复制到子目录中的另一个路径 - How to read the column of text file using Linux shell script and copy the files to another path with in sub directories Linux Shell命令将文本数据从文件复制到另一个文件 - Linux shell command to copy text data from a file to another 如何从Windows环境运行Linux服务器上的Shell脚本? - How to run shell script located on Linux server from Windows environment? FTP 问题从 Linux 到 windows 服务器通过 Z2591C98B70119FE62489Z 脚本 - FTP issue from Linux to windows server through shell script 使用 shell 脚本将特定单词从一个文件复制到另一个文件 - Copy specific word from a file to another file using shell script Linux Shell脚本:将文件和字符串一起写入另一个文件 - Linux Shell Script: Writing file and string together to another file 从Shell脚本在另一台Linux服务器上远程执行命令 - Executing command remotely on another linux server from a shell script 如何将windows批处理文件转换为linux shell脚本? - How convert windows batch file to linux shell script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM